Announcement

Collapse
No announcement yet.

Installing and using Strace On Linux Servers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Installing and using Strace On Linux Servers

    Strace is a Linux command that allows you to follow what a process on your server is doing. strace is a powerful command line tool for debugging and trouble shooting programs in Unix-like operating systems such as Linux. It captures and records all system calls made by a process and the signals received by the process.

    Let's say process 351711 has been running for an extended period, and you're wondering if it's doing anything, or it's hung/stuck - strace is perfect for such situations! First of all, we need to install it.


    If strace is not pre-installed on your Linux system, run the appropriate command below for your distribution, to install it.

    Code:
    $ sudo apt install strace    #Debian/Ubuntu 
    # yum install strace        #RHEL/CentOS
    # dnf install strace        #Fedora 22+

    Once it's installed, it's as simple as running strace -p PID (where PID is the process ID).

    If there's no process running, you'll see something like this:

    Code:
    # strace -p 351711
    Output:
    strace: attach: ptrace(PTRACE_ATTACH, ...): No such process

    And If a process is already running, above command will fill your screen with continues output that shows system calls being made by the process, to end it, press Ctrl+c


    For additional information, see the strace man page.
    Code:
    $ man strace
Working...
X