I'm looking for a way to "stack" commands from the terminal prompt so that only one at the time is executed:
- First enter a command, press enter, execution starts, back to shell (like
&
) - I can enter a second command. I press enter, the first command is not completed yet so it is stacked (unlike
&
). But again, the prompt is back.
Kind of a mix between:
&
to launch in the background, but the second command would run at the same time as the first one, and I don't want that;&&
or;
to launch one command after the other, but you have to write them all in once. I want to regain the prompt after the command is executed or stacked.
The closest I've found would be:
$ cmd1 &
$ wait; cmd2 &
But I'm looking for something a bit more potent, allowing me to view pending, failed and completed commands. Maybe something like:
$ stackit cmd1
cmd1 started
$ stack it cmd2
cmd2 queued
$ stack it cmd3
cmd3 queued
$ stack it --
[1] running
[2] queued
[3] queued
Maybe to even allow for some parallelism, like 2 commands at the time.
This seems fairly generic so I don't feel like re-inventing the wheel.
Use cases:
- Copying files to and from an old NAS that suffers when several operations run at the same time
- wget on a large number of files where a limited number of connections would be preferred
addcommand <command>
to add a command to the (a) queue. Overkill?