If I've started a process that turns out to be long-running, can I "queue up" a command to run immediately after it?
I know I can do this with cmd1 && cmd2
syntax if I was starting from scratch, but what if cmd1 is already running?
Using the && Operator. We should note that the && operator executes the second command only if the first one returns an exit code of 0. If we want to run the next script, even if the first one fails, we can replace the && operator with the; operator, which runs the next command regardless of the exit code.
The bash WAIT command is used to halt the execution of a script until all background jobs or specified JobID/PIDs terminate successfully and return an expected exit code to trigger the next command that was “waited for.”
Using double ampersands (&&) introduces error checking. The second command will run only if the first command is successful.
You can press C-z to stop the current foreground task, then type "fg %%; some-other-command" to resume the task and run another command afterwards.
If the currently-running command isn't reading input, you can just type the command in the same window. Bash will read the input and run the command when the current one finishes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With