Suppose I have jobs to run one after another, how can I queue them up and if possible still retain the output/log each script produces. (eg. I can use at to schedule tasks but I dont get the log/output of each app)
If you want to run several commands interactively, just separate them with a semicolon:
foo ; bar ; baz
If you want to queue a batch of commands to be executed in the background when the system isn't too busy and possibly after you have logged out, you can use the
batch command. The output of jobs run with
cron is emailed to you. For that to work, you need to setup a local mail server.
Write the commands with && between them eg :
command1 && command2
Note : the second command won't be executed if the first command returns an error
If this is a long list of commands, or you're going to do this often enough, I would make a script to do it for you.
shell scripts of this nature are extremely easy.
#!/bin/bash foo bar baz
Simply put this text into a file, turn execution on (
chmod +x myscript) and then
./myscript and off you go.
This will execute commands
baz in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide