I have a situation where I have a process, say script.pl
(here it is), which seems to stick around in the output to ps auxw | grep script.pl
, sometimes when load is heavy it sticks around for several minutes. This script is called 5-10 times a second by another process (this process does a nonblocking call to the script like this: System(/some/path/script.pl &)
).
At first I was worried that this script was for some reason failing to complete in a timely fashion and thus slowing other things down. However, all the script does is write a message to another box via a TCP socket.
And that's where things get weird. 1) I can verify this socket operation (the only thing the script does) completes by viewing the logs on the other box -- it gets the message immediately and on time. 2) Even though I see many instances of (seemingly completed) script.pl
instances in ps
output, I do not see corresponding entries if I do something like top -n 1 | grep script.pl
-- this seems to indicate script.pl
isn't using any resources; in fact there are no instances at all of script.pl
in this output.
So finally, are there any known issues with ps
or the Perl interpreter that could lead to completed Perl scripts hanging around in ps
output, but not top
output?
Thanks!
EDIT: I changed the top command call to: top -n 1 -u script_pl_user | grep script.pl
. Now the process shows up equally in both places. However, in top
, it's showing CPU usage of 0.0% and no or very very very small memory usage. Why is script.pl sticking around even though its operations are verified to be completed?
top
shows onlyn
processes, wheren
depends on the terminal size. By default it's ordered by CPU usage, so you won't see processes which don't use the CPU too much. So why do you expect your script should be listed in this (truncated) top list?ps ax
shows all processes.top -n 1 -u script_pl_user | grep script.pl
. My main question remains, why is script.pl still showing up intop
andps
even though the operation it was supposed to do is verified to be completed? Why are they sticking around?