Join 3,557 readers in helping fund MetaFilter (Hide)


How do you kill a RHEL process that you cannot see?
July 18, 2013 12:34 PM   Subscribe

How can you kill a RHEL process that does not show up in either top or ps -ef?

I ran a perl script designed to send out messages continuously in order to test a notification system I'm working on. I closed the terminal window, so I was unable to ctrl-C and stop the perl script execution. The perl script didn't show up in either top or ps -ef. My solution of rebooting the workstation worked, but was a little bit inelegant. I'm just a user and I can't get root.

In the future I will not close the terminal window of course, but I'd still like to know how to stop a process I can't see.
posted by Rob Rockets to Computers & Internet (10 answers total) 1 user marked this as a favorite
 
Are you sure you can't find it?

Do something like:

ps -ef | grep foo

Replace foo with the name of your Perl script.
posted by Blazecock Pileon at 12:42 PM on July 18, 2013


Could it have turned into a zombie / defunct process?
posted by nostrada at 12:48 PM on July 18, 2013 [1 favorite]


Try
ps wwwaux
to find it next time.

Also, are you sure the process didn't terminate?
posted by ellenaim at 12:56 PM on July 18, 2013


If it's still running, it should show up in ps -ef

Any chance that it already stopped when you logged out? Normally when you log out, the shell sends foreground tasks SIGHUP, which, unless they do something special to ignore it, causes them to exit.

Whether background jobs are treated the same way depends on the shell option huponexit (accessible with shopt). I think RHEL has that option off by default.

You can prevent this with the utility nohup.
posted by aubilenon at 12:58 PM on July 18, 2013


Agreed: normally if you don't arrange things otherwise, any processes you start in a terminal will be killed off when you close that terminal (they get a HUP, hangup, signal— the name dates back to when your terminal was a literal terminal connected over a phone line).

(A process can choose to do something else when it gets a HUP, and programs like screen, tmux, or nohup can detach the process from your terminal so it doesn't get a HUP when the terminal closes, but in your case these special circumstances don't apply.)
posted by hattifattener at 1:09 PM on July 18, 2013


There are no processes that aren't visible to root unless you've inserted something into the kernel to hide things. If it doesn't show up on ps -e, it isn't running.
posted by introp at 2:19 PM on July 18, 2013


Could it have turned into a zombie / defunct process?

unlikely, given the description. if it survived the death of its terminal it would have been adopted by init (which reaps dead children). also, zombies will still appear in the output from ps (and top), but with a state of "Z".
posted by russm at 2:48 PM on July 18, 2013 [1 favorite]


Perl scripts sometimes show up in ps as simply "/usr/bin/perl" or just "perl" rather than the name of the script.
posted by tylerkaraszewski at 2:52 PM on July 18, 2013 [2 favorites]


nthing what aubilenon said. It sounds like the process had already terminated (unless you were still seeing its side-effects, in which case that's very weird).
posted by gmb at 4:34 PM on July 18, 2013


Since it was being used to test a notification system, could there simply have been a backlog of notifications that still had to be processed after the perl script had terminated?
posted by pharm at 3:50 AM on July 19, 2013


« Older My wife and I want to visit Ye...   |  The bf and I have started talk... Newer »
This thread is closed to new comments.