How to queue commands
up vote
3
down vote
favorite
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)
scripts scheduled
add a comment |
up vote
3
down vote
favorite
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)
scripts scheduled
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
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)
scripts scheduled
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)
scripts scheduled
scripts scheduled
asked Aug 4 '11 at 13:47
Jiew Meng
3,259206391
3,259206391
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
4
down vote
accepted
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 batch
, at
, or cron
is emailed to you. For that to work, you need to setup a local mail server.
+1, unless you have a specific reason to use&&
, this is better.
– user606723
Aug 4 '11 at 17:05
add a comment |
up vote
3
down vote
Write the commands with && between them eg : command1 && command2
Note : the second command won't be executed if the first command returns an error
1
You can separately save the stdout of each with normal bash redirection:command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
add a comment |
up vote
1
down vote
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 foo
, bar
, and baz
in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
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 batch
, at
, or cron
is emailed to you. For that to work, you need to setup a local mail server.
+1, unless you have a specific reason to use&&
, this is better.
– user606723
Aug 4 '11 at 17:05
add a comment |
up vote
4
down vote
accepted
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 batch
, at
, or cron
is emailed to you. For that to work, you need to setup a local mail server.
+1, unless you have a specific reason to use&&
, this is better.
– user606723
Aug 4 '11 at 17:05
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
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 batch
, at
, or cron
is emailed to you. For that to work, you need to setup a local mail server.
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 batch
, at
, or cron
is emailed to you. For that to work, you need to setup a local mail server.
answered Aug 4 '11 at 14:17
psusi
30.9k14986
30.9k14986
+1, unless you have a specific reason to use&&
, this is better.
– user606723
Aug 4 '11 at 17:05
add a comment |
+1, unless you have a specific reason to use&&
, this is better.
– user606723
Aug 4 '11 at 17:05
+1, unless you have a specific reason to use
&&
, this is better.– user606723
Aug 4 '11 at 17:05
+1, unless you have a specific reason to use
&&
, this is better.– user606723
Aug 4 '11 at 17:05
add a comment |
up vote
3
down vote
Write the commands with && between them eg : command1 && command2
Note : the second command won't be executed if the first command returns an error
1
You can separately save the stdout of each with normal bash redirection:command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
add a comment |
up vote
3
down vote
Write the commands with && between them eg : command1 && command2
Note : the second command won't be executed if the first command returns an error
1
You can separately save the stdout of each with normal bash redirection:command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
add a comment |
up vote
3
down vote
up vote
3
down vote
Write the commands with && between them eg : command1 && command2
Note : the second command won't be executed if the first command returns an error
Write the commands with && between them eg : command1 && command2
Note : the second command won't be executed if the first command returns an error
edited Aug 4 '11 at 14:28
answered Aug 4 '11 at 14:00
danjjl
4,53122343
4,53122343
1
You can separately save the stdout of each with normal bash redirection:command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
add a comment |
1
You can separately save the stdout of each with normal bash redirection:command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
1
1
You can separately save the stdout of each with normal bash redirection:
command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
You can separately save the stdout of each with normal bash redirection:
command1 > afile && command2 > anotherfile
– kyleN
Aug 4 '11 at 16:28
add a comment |
up vote
1
down vote
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 foo
, bar
, and baz
in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide
add a comment |
up vote
1
down vote
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 foo
, bar
, and baz
in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide
add a comment |
up vote
1
down vote
up vote
1
down vote
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 foo
, bar
, and baz
in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide
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 foo
, bar
, and baz
in order assuming that all of them block.
If you ever want to do something more complicated see the Advanced Bash-Scripting Guide
answered Aug 4 '11 at 17:09
user606723
1,6811014
1,6811014
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f55819%2fhow-to-queue-commands%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown