Bash – Queue a task in a running shell

bashfishjob-control

I often start a long running command that is bound to either CPU, Disk, RAM or Internet connection. While that is running, I find that I want to run a similar command. Let's say downloading something big.

Then I start a shell with wget ...1 and let it run. I could open another shell and run the other wget ...2, but now they would fight for the bandwidth. When I just type the second command into the running shell, it will execute that later on, since wget is not interactive.

Is there a reasonable way to do this with either Bash or Fish Shell?

Best Answer

If you have already running wget http://first in foreground you can pause it with CTRL+z and then return it back to work with another command right after it:

fg ; wget http://second

It should work in most cases.

If that way is not acceptable, you should go with lockfile. Or even just to monitor the process via ps (lockfile is better).