How would I determine which script is being executed by a process? When I use:
ps -u user
I get the following output:
10005194 26932 0.0 0.0 112700 1544 ? Ss Jun03 0:00 -bash
10005194 27117 0.0 0.0 112700 1528 ? Ss Apr24 0:00 -bash
10005194 27164 0.0 0.0 112700 2040 ? Ss Jun06 0:00 -bash
10005194 27404 0.0 0.0 112700 1544 ? Ss May27 0:00 -bash
10005194 27484 0.0 0.0 112700 1528 ? Ss Apr23 0:00 -bash
10005194 27531 0.0 0.0 112700 1528 ? Ss May22 0:00 -bash
...
There are hundreds of lines. I know that there are a number of scripts that this user is executing, but I would like to narrow down which of the scripts is holding onto threads. Is there a way to do this?
Use the w
(for "wide") option.
From man ps
(search for wide
):
w
Wide output. Use this option twice for unlimited width.
e.g. ps ww -u cas
:
$ ps ww -U cas | grep bash
1350 pts/0 Ss 0:00 -bash
18345 pts/34 S 0:00 /bin/bash /home/cas/bin/myscript.sh
21293 pts/34 Ss+ 0:00 bash
The -bash
is a login shell.
The plain bash
is a non-login interactive shell - the tty pts/34
is the same so you can tell that it is the parent shell (or distant grand-parent) of the myscript.sh
bash shell.
Using /usr/env/bin bash prevents you from determining which script is running. Instead you should specify exactly were the bash executable is for the machine you're running on.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments