2

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?

gora
  • 21
  • 1
  • 2
  • 1
    Questions about usage of general Unix tools like `nohup` should be asked on the [Super User site](http://superuser.com/). –  Oct 21 '13 at 08:45
  • "prevent nohup from doing this". From doing what ? – Slyx Dec 29 '15 at 09:52

3 Answers3

2

The command I usually do this is to use:

killall -u [USER]
Volker Siegel
  • 16,983
  • 5
  • 52
  • 79
  • Or, if you feel daring, `kill -15 -1` as your non-root mpi-user (which logs you out, too). – Ned64 Mar 28 '18 at 19:53
1

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

Slyx
  • 3,845
  • 2
  • 19
  • 25
1

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: https://stackoverflow.com/questions/5433697/terminating-all-processes-with-mpi).

suszterpatt
  • 263
  • 1
  • 3
  • 7