Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have started a program in parallel using the command:

    nohup mpirun -7 mylongprogram.py &

I now want to terminate the program. When I want to kill the process by the command:

    kill -9 <PID>

I see that another process with a different PID is started. How do I kill the entire mpi program and prevent nohup from doing this?

share|improve this question

migrated from stackoverflow.com Nov 4 '13 at 0:37

This question came from our site for professional and enthusiast programmers.

Questions about usage of general Unix tools like nohup should be asked on the Super User site. – Hristo Iliev Oct 21 '13 at 8:45
"prevent nohup from doing this". From doing what ? – Slyx Dec 29 '15 at 9:52

Instead of forcing the program to shut down from the outside, I'd try triggering a clean exit from inside. For example, create a file somewhere that the program periodically checks if it exists, and shuts itself down if it does (related reading: Terminating all processes with MPI).

share|improve this answer

The command I usually do this is to use:

killall -u [USER]
share|improve this answer

killall mpirun

or more specifically for your case :

ps -ef | grep mpirun | grep mylongprogram | awk '{print $2}' | while read p; do kill -9 $p ; done

share|improve this answer

Your Answer


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.