This Python script allows you to trace one or more running processes using the strace
command-line tool from a single application. It finds processes by their PID from the application name and creates a log file for each traced process.
- Python 3.x
strace
tool (available on most Linux distributions)psutil
Python library (install it usingpip install psutil
)
-
Clone or download this repository to your local machine.
-
Open a terminal and navigate to the directory where the script is located.
-
Run the script with the following command:
python3 pypidtrace.py <target_process_name>
Replace
<target_process_name>
with the name of the process you want to trace. -
The script will create log files for each traced process with the format
trace_pid_<pid>.log
, where<pid>
is the process ID of the traced process. -
Once the tracing is complete, the script will check if the traced processes have exited and report their status.
To trace a process named "myapp," run the following command:
python3 pypidtrace.py myapp
The script will start tracing all processes named "myapp" and create log files for each traced process.