darkguy2008 / parallelshell

Run multiple shell commands in parallel
501 stars 44 forks source link

Is there a way to close after N seconds? #40

Open bahmutov opened 8 years ago

bahmutov commented 8 years ago

I am using parallelshell to perform end 2 end testing, like starting a server and then making a request from another script. Most of the time, there is no error, and the request script finishes with exit code 0. Is there an option to kill everything after N second timeout if the processes have not finished before with a non-zero code?

Yaakov-Belch commented 8 years ago

Here is a solution that works with the current parallelshell:

parallelshell your_programs 'perl -we "sleep 10; exit 2;"'

This adds to your list one process that waits 10 seconds (you can change this number) and then fails. Parallelshell with detect this failure and kill all the other processes.