strace cp /home/user/data /home/user2/data
veya herhangi bir processi de direk takip etmek için kullanabilirsiniz
# strace -p 22903
strace: Process 22903 attached
epoll_wait(4, [{EPOLLIN, {u32=747938480, u64=94331114660528}}], 12, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {5423879, 642853153}) = 0
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1a\2\0\0Dy\1\0\235\0\0\0\1\1o\0.\0\0\0", 24}], msg_contr ollen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/unit/h"..., 761}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 761
epoll_wait(4, [{EPOLLIN, {u32=747938480, u64=94331114660528}}], 12, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {5423879, 643121667}) = 0
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1\304\2\0\0Ey\1\0\235\0\0\0\1\1o\0.\0\0\0", 24}], msg_co ntrollen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/unit/h"..., 860}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 860
epoll_wait(4, [{EPOLLIN, {u32=747938480, u64=94331114660528}}], 12, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {5423889, 653569379}) = 0
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1a\2\0\0Fy\1\0\235\0\0\0\1\1o\0.\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/unit/h"..., 761}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 761
epoll_wait(4, [{EPOLLIN, {u32=747938480, u64=94331114660528}}], 12, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {5423889, 653974944}) = 0
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1\304\2\0\0Gy\1\0\235\0\0\0\1\1o\0.\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(12, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/unit/h"..., 860}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 860
epoll_wait(4, [{EPOLLIN, {u32=747938480, u64=94331114660528}}], 12, -1) = 1
clock_gettime(CLOCK_BOOTTIME, {5423899, 664702235}) = 0
socket(AF_LOCAL, SOCK_DGRAM|SOCK_CLOEXEC, 0) = 17
sendmsg(17, {msg_name(21)={sa_family=AF_LOCAL, sun_path="/run/systemd/notify"}, msg_iov(1)=[{"WATCHDOG=1", 10}], msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 10
close(17) = 0
çıktıyı bir yere kaydetmek için
strace -o /tmp/PID_takip -p 2845
Strace ile çıktı satırı maksimum 32 karakterdir ancak bu uzatılabilir
strace -o /tmp/PID_takip -p 2845 -s 256
En güzel çıktılarından biride hani çağrının ne kadar yapıldığını gösteren sayaç tarzı çıktıdır. Komutu verdikten sonra durdurmak icin CTRL-C
strace -p 22903 -c
strace: Process 22903 attached
^Cstrace: Process 22903 detached
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
56.16 0.000082 82 1 sendmsg
26.71 0.000039 39 1 socket
5.48 0.000008 4 2 epoll_wait
3.42 0.000005 5 1 close
3.42 0.000005 1 4 recvmsg
3.42 0.000005 5 1 timerfd_settime
1.37 0.000002 1 2 clock_gettime
------ ----------- ----------- --------- --------- ----------------
100.00 0.000146 12 total
Strace’de herşeyi takip edemeyebilirsiniz. Bazı yazılımlarda bu engellenebilir
strace -p 295
strace: attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted
]]>