Thursday, August 22, 2013

Queue command to run after existing command finishes

Credit goes to this post at superuser. Probably due to poor planning/pipeline development, I sometimes want to queue up some other commands execute after an existing, long-running process has already been running for a while. I use Ctrl-z (pause) and fg (foreground) for this.
#Execute a long running program
./long_running_program.sh
#Realize you want to have another program execute after the first concludes, and hit Control-z to pause
^Z
#Set up a bash command to resume the paused program with fg, and run the next in queue.
fg; ./next_long_running_program.sh

No comments:

Post a Comment