How to terminate parallel GNU work without killing work orders?

I run a bunch of shell scripts, for example, parallel -a my_scripts bash

and at some point I decided that I was running enough and would like to stop creating new jobs and just let all existing jobs finish. In other words, I want to kill the parent process without killing the children.

It seems like there are ways to control the shutdown when GNU parallel is first started (for example, if I know ahead of time I only want to start x

, then I can use an argument --halt now,success=x

), but I couldn't find how to control GNU parallel when it was already running.

Of course, I can just CTRL+C

kill the parallel and repeat the tasks that were interrupted, but I thought there might be a smarter way.

+3


source to share


1 answer


I understood that. The answer is to just send SIGTERM

to the parent process parallel

(just kill

its PID will do it). parallel

then replies with the following (in this case I have 4 assignments):

parallel: SIGTERM received. No new jobs will be started.
parallel: Waiting for these 4 jobs to finish. Send SIGTERM again to stop now.

      



I dug it out from the man page:

FULL WORKS BUT DON'T START NEW WORKS
If you regret starting a lot of jobs, you can just split GNU in parallel, but if you want to avoid having half-full jobs you have to send a SIGTERM signal to GNU in parallel:

killall -TERM parallel

This will tell GNU in parallel not to start any new jobs, but wait until the current job orders are completed before exiting.

+5


source







All Articles