Is there a way I can do the following in a unix terminal:
- Start a long running process
- Add another long running process to start when the previous is done
- Repeat step 2 until I have queued the processes I need to have run
Reason I ask is that I have some long running stuff I need to do. I could put all the commands in a simple bash script and just execute that, but the problem is that I am not always sure exactly what I need to run. So if I start the script and then remember another one I should run, I need to hit ^C a bunch of times until all the processes are killed, edit the script and add my new process and then start the whole thing again.
What I specifically am doing right now is to copy a lot of large files on to various external hard drives, and since I don't know exactly which ones I need to copy and to where right now I'd like to start the ones I do know I need to copy, and then add to the queue as I figure out the rest.
Hope that made sense… Is anything like this possible?
Best Answer
The shell is perfect for that.
Ctrl-z
to suspend the program.Now run the queue like this:
You may not suspend this while loop or exit bash until the queue is done.
If you will need to log out (e.g. the programs will run for many days) then consider running the above steps in
screen
.