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)










share|improve this question


























    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)










    share|improve this question
























      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)










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 4 '11 at 13:47









      Jiew Meng

      3,259206391




      3,259206391






















          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.






          share|improve this answer





















          • +1, unless you have a specific reason to use &&, this is better.
            – user606723
            Aug 4 '11 at 17:05




















          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






          share|improve this answer



















          • 1




            You can separately save the stdout of each with normal bash redirection: command1 > afile && command2 > anotherfile
            – kyleN
            Aug 4 '11 at 16:28




















          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






          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            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

























            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.






            share|improve this answer





















            • +1, unless you have a specific reason to use &&, this is better.
              – user606723
              Aug 4 '11 at 17:05

















            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.






            share|improve this answer





















            • +1, unless you have a specific reason to use &&, this is better.
              – user606723
              Aug 4 '11 at 17:05















            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.






            share|improve this answer












            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            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




















            • +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














            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






            share|improve this answer



















            • 1




              You can separately save the stdout of each with normal bash redirection: command1 > afile && command2 > anotherfile
              – kyleN
              Aug 4 '11 at 16:28

















            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






            share|improve this answer



















            • 1




              You can separately save the stdout of each with normal bash redirection: command1 > afile && command2 > anotherfile
              – kyleN
              Aug 4 '11 at 16:28















            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






            share|improve this answer














            Write the commands with && between them eg : command1 && command2



            Note : the second command won't be executed if the first command returns an error







            share|improve this answer














            share|improve this answer



            share|improve this answer








            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
















            • 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












            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






            share|improve this answer

























              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






              share|improve this answer























                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






                share|improve this answer












                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







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 4 '11 at 17:09









                user606723

                1,6811014




                1,6811014






























                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                    How to change which sound is reproduced for terminal bell?

                    Can I use Tabulator js library in my java Spring + Thymeleaf project?