Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Last night I launched a command via nohup on a cluster and then closed the connection. Today I would like to kill this job (I know it's still running because output is being generated in an output file) but I can't even determine its PID. If I type ps -ax, for instance, the name of my executable does not show up. Just typing ps only shows me executables that I have launched this login session.

Any suggestions?

share|improve this question
    
I use $ps -ef all the time. For me it shows all process (even not owned by me) on linux hosts. Does it help for you ? Get the pid and kill it. –  Naai Sekar May 28 '13 at 14:43
add comment

2 Answers

You can use lsof to find the pid of what has that output file open.

share|improve this answer
    
lsof:command not found. Cluster is running Red Hat: Scientific Linux SL release 5.5 (Boron) –  alexvas Feb 16 '13 at 21:40
    
Run it as root. –  Dennis Kaarsemaker Feb 16 '13 at 21:42
    
I don't have root access on the cluster... Also, why would a command be recognized by root but not by another user? –  alexvas Feb 16 '13 at 22:02
    
Becaue on RHEL 5 and clones, /sbin and /usr/sbin are not in normal users' $PATH. You can use the full path, but lsof works best as root. –  Dennis Kaarsemaker Feb 16 '13 at 22:07
add comment

do you remeber the name of the process? Try to list with:

ps aux | grep -i $your_process_name

If you find that process you can easily kill it with ($pid = second column):

kill -9 $pid

You will not find that process in your current session, the nohup executed the given program then detached the program from your terminal. This parent-less process's parent will now be the init process (PID #1). You can see this with the command:

pstree -a

If you are sure, only one instance of given process is running you can easily kill with this:

killall -9 $process_name

for example:

killall -9 nano
share|improve this answer
    
pgrep is probably a better tool here than killall, since it can selectively search for the process name (with -f) and only select processes started by the user (-u) –  jsbillings Sep 1 '13 at 13:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.