On previous questions similar to mine, the proposed solutions are all involved suspending the current foreground task with Ctrl+Z and then running fg && ...
or fg ; ...
(and maybe sending the old task to the background bg
first, so that it can continue running while the new command is being typed).
At least for me this only works with a single queued command. When I try using this trick multiple times in a row, the middle commands are forgotten:
$ sleep 60 && echo test1
^Z
[1] + 2336348 suspended sleep 60
$ fg && echo test2
[1] + 2336348 continued sleep 60
^Z
[1] + 2336348 suspended sleep 60
$ fg && echo test3
[1] + 2336348 continued sleep 60
test3
Note how test1
was never printed (though I could live with that, this is just because my initial command consisted of two and my sleep 60
was fully executed, which is what I care about most). More importantly, note how test2
was never printed. This was my second command and I believe it was never executed.
What I want is to enqueue another command that I just thought of (while other commands were running) so that it runs after the current command and after/before all other commands that I have enqueued before. The ordering of the commands ultimately doesn't matter, but they cannot run simultaneously (otherwise I could just open another shell and run them there) because they depend on some common state (file system or so).
Thanks for your help!