我的个人博客网站最近被攻击了,被用来发送一些垃圾邮件。但是我不知道这个进程是怎么来的,用top查看发现一个不知道干什么的perl脚本,决定给用strace查看一下。

strace可以追踪一个进程的系统调用通过pid,像:

strace -vvtf -p 1234

但是这个perl脚本的进程结束的太快了,不能用捕获pid然后strace它。

用下边这个脚本,可以通过进程名称追踪一个未开始的进程:

while true; do 
    pid=$(pgrep 'processname' | head -1); 
    if [[ -n "$pid" ]]; then 
        strace  -s 2000 -vvtf -p "$pid";
        break; 
    fi; 
done    

这个技巧可以被用来strace一些不知道pid或者在捕获到pid前就已经结束的进程。

 

原文地址:http://konrness.com/linux/how-to-strace-a-process-that-has-not-started-yet/

相关文章:

  • 2022-01-17
  • 2021-12-31
  • 2022-12-23
  • 2021-11-03
  • 2021-11-08
  • 2021-05-27
  • 2021-09-27
猜你喜欢
  • 2021-11-10
  • 2021-11-10
  • 2021-10-28
  • 2021-07-12
  • 2022-02-12
  • 2022-12-23
  • 2021-09-13
相关资源
相似解决方案