Search code examples
unixjobs

Run a job after another


In unix/linux, I have a job ./a.out, which is currently running in the background over ssh as

nohup ./a.out &

And I have logged out of the original shell. I want another job ./b.out to start running only after ./a.out finishes. How to do it? The overall effect is equivalent to

./a.out && ./b.out

But I do not want to kill ./a.out.

Edit: clarify that ./a.out is running in the background using nohup. (Thanks to Marc B.)


Solution

  • One approach would be to see what the process ID of a.out is, with top or ps, and have a launcher program that checks once a second to see if that PID is still active. When it isn't, the launcher runs b.out.