& at the end of command












2














I have startup script line:



pyprogramm >> /dev/null  2>&1 &


Meanings:



>> /dev/null - redirect stdout to null device
2>&1 - redirect stderr to stdout (that is redirected to null device)


but what very last & means?










share|improve this question






















  • Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
    – Ravexina
    1 hour ago


















2














I have startup script line:



pyprogramm >> /dev/null  2>&1 &


Meanings:



>> /dev/null - redirect stdout to null device
2>&1 - redirect stderr to stdout (that is redirected to null device)


but what very last & means?










share|improve this question






















  • Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
    – Ravexina
    1 hour ago
















2












2








2







I have startup script line:



pyprogramm >> /dev/null  2>&1 &


Meanings:



>> /dev/null - redirect stdout to null device
2>&1 - redirect stderr to stdout (that is redirected to null device)


but what very last & means?










share|improve this question













I have startup script line:



pyprogramm >> /dev/null  2>&1 &


Meanings:



>> /dev/null - redirect stdout to null device
2>&1 - redirect stderr to stdout (that is redirected to null device)


but what very last & means?







bash scripts lubuntu stdout






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









vico

1,12472345




1,12472345












  • Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
    – Ravexina
    1 hour ago




















  • Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
    – Ravexina
    1 hour ago


















Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
– Ravexina
1 hour ago






Runs the program in background..., Related: askubuntu.com/questions/106351/… also related: superuser.com/questions/513496/…
– Ravexina
1 hour ago












2 Answers
2






active

oldest

votes


















2














It means run the command in the background. The calling script continues rather than blocking until the called command completes.






share|improve this answer





























    2














    What is the & terminator ?



    The trailing & operator at the end of a command is used to put commands into background. This is actually a standard syntax specified by POSIX standard:




    Asynchronous Lists



    If a command is terminated by the control operator
    ( '&' ), the shell shall execute the command
    asynchronously in a subshell. This means that the shell shall not wait
    for the command to finish before executing the next command.



    The format for running a command in the background is:



    command1 & [command2 & ... ]




    From the definition you can see that & also serves as command terminator for lists of commands, much like ; does. In your specific example, pyprogramm >> /dev/null 2>&1 & there is only one command in the list.



    Sequential ; lists vs asynchronous & lists



    More generally,



    echo Hello ; echo World ;


    and



    echo Hello & echo World &


    are two examples of lists terminated by the ; and & operators, with the difference that & terminated list will hide the output by redirecting output to /dev/null if job control is enabled, and in fact that's exactly what the standard also states:




    If job control is disabled (see set, -m), the standard input for an
    asynchronous list, before any explicit redirections are performed,
    shall be considered to be assigned to a file that has the same
    properties as /dev/null. This shall not happen if job control is
    enabled. In all cases, explicit redirection of standard input shall
    override this activity.




    Thus, in the specific example redirecting >> /dev/null may be unnecessary, if job control is enabled by the shell.



    Note also, that from the definition we mentioned earlier, & executes commands in subshell. By contrast, the ; terminated list is executed in current shell. There's also difference in exit statuses. For & the standard says:




    The exit status of an asynchronous list shall be zero.




    This is significant when you want to put multiple commands in background. When you write a script or command you will have to chose commands for which you don't care if they failed or not, or you will have to find a way to handle the non-zero ( error ) exit status. In your specific example, pyprogramm >> /dev/null 2>&1 & running in background should have some way of indicating if it failed or not, however judging that you use 2>&1 you are hiding error output by redirecting, and you probably assume the script should not fail.



    By contrast, ; exit status is defined as:




    The exit status of a sequential list shall be the exit status of the
    last command in the list.




    Again, this has implications on how you write a sequential list of commands in command-line and how you want things to be handled if some of the commands in the list failed.





    The fact that this is POSIX definition means that all Bourne-like shells, meaning bash, dash, and ksh must support it.






    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',
      autoActivateHeartbeat: false,
      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%2f1107124%2fat-the-end-of-command%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      It means run the command in the background. The calling script continues rather than blocking until the called command completes.






      share|improve this answer


























        2














        It means run the command in the background. The calling script continues rather than blocking until the called command completes.






        share|improve this answer
























          2












          2








          2






          It means run the command in the background. The calling script continues rather than blocking until the called command completes.






          share|improve this answer












          It means run the command in the background. The calling script continues rather than blocking until the called command completes.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Robert Longson

          259410




          259410

























              2














              What is the & terminator ?



              The trailing & operator at the end of a command is used to put commands into background. This is actually a standard syntax specified by POSIX standard:




              Asynchronous Lists



              If a command is terminated by the control operator
              ( '&' ), the shell shall execute the command
              asynchronously in a subshell. This means that the shell shall not wait
              for the command to finish before executing the next command.



              The format for running a command in the background is:



              command1 & [command2 & ... ]




              From the definition you can see that & also serves as command terminator for lists of commands, much like ; does. In your specific example, pyprogramm >> /dev/null 2>&1 & there is only one command in the list.



              Sequential ; lists vs asynchronous & lists



              More generally,



              echo Hello ; echo World ;


              and



              echo Hello & echo World &


              are two examples of lists terminated by the ; and & operators, with the difference that & terminated list will hide the output by redirecting output to /dev/null if job control is enabled, and in fact that's exactly what the standard also states:




              If job control is disabled (see set, -m), the standard input for an
              asynchronous list, before any explicit redirections are performed,
              shall be considered to be assigned to a file that has the same
              properties as /dev/null. This shall not happen if job control is
              enabled. In all cases, explicit redirection of standard input shall
              override this activity.




              Thus, in the specific example redirecting >> /dev/null may be unnecessary, if job control is enabled by the shell.



              Note also, that from the definition we mentioned earlier, & executes commands in subshell. By contrast, the ; terminated list is executed in current shell. There's also difference in exit statuses. For & the standard says:




              The exit status of an asynchronous list shall be zero.




              This is significant when you want to put multiple commands in background. When you write a script or command you will have to chose commands for which you don't care if they failed or not, or you will have to find a way to handle the non-zero ( error ) exit status. In your specific example, pyprogramm >> /dev/null 2>&1 & running in background should have some way of indicating if it failed or not, however judging that you use 2>&1 you are hiding error output by redirecting, and you probably assume the script should not fail.



              By contrast, ; exit status is defined as:




              The exit status of a sequential list shall be the exit status of the
              last command in the list.




              Again, this has implications on how you write a sequential list of commands in command-line and how you want things to be handled if some of the commands in the list failed.





              The fact that this is POSIX definition means that all Bourne-like shells, meaning bash, dash, and ksh must support it.






              share|improve this answer




























                2














                What is the & terminator ?



                The trailing & operator at the end of a command is used to put commands into background. This is actually a standard syntax specified by POSIX standard:




                Asynchronous Lists



                If a command is terminated by the control operator
                ( '&' ), the shell shall execute the command
                asynchronously in a subshell. This means that the shell shall not wait
                for the command to finish before executing the next command.



                The format for running a command in the background is:



                command1 & [command2 & ... ]




                From the definition you can see that & also serves as command terminator for lists of commands, much like ; does. In your specific example, pyprogramm >> /dev/null 2>&1 & there is only one command in the list.



                Sequential ; lists vs asynchronous & lists



                More generally,



                echo Hello ; echo World ;


                and



                echo Hello & echo World &


                are two examples of lists terminated by the ; and & operators, with the difference that & terminated list will hide the output by redirecting output to /dev/null if job control is enabled, and in fact that's exactly what the standard also states:




                If job control is disabled (see set, -m), the standard input for an
                asynchronous list, before any explicit redirections are performed,
                shall be considered to be assigned to a file that has the same
                properties as /dev/null. This shall not happen if job control is
                enabled. In all cases, explicit redirection of standard input shall
                override this activity.




                Thus, in the specific example redirecting >> /dev/null may be unnecessary, if job control is enabled by the shell.



                Note also, that from the definition we mentioned earlier, & executes commands in subshell. By contrast, the ; terminated list is executed in current shell. There's also difference in exit statuses. For & the standard says:




                The exit status of an asynchronous list shall be zero.




                This is significant when you want to put multiple commands in background. When you write a script or command you will have to chose commands for which you don't care if they failed or not, or you will have to find a way to handle the non-zero ( error ) exit status. In your specific example, pyprogramm >> /dev/null 2>&1 & running in background should have some way of indicating if it failed or not, however judging that you use 2>&1 you are hiding error output by redirecting, and you probably assume the script should not fail.



                By contrast, ; exit status is defined as:




                The exit status of a sequential list shall be the exit status of the
                last command in the list.




                Again, this has implications on how you write a sequential list of commands in command-line and how you want things to be handled if some of the commands in the list failed.





                The fact that this is POSIX definition means that all Bourne-like shells, meaning bash, dash, and ksh must support it.






                share|improve this answer


























                  2












                  2








                  2






                  What is the & terminator ?



                  The trailing & operator at the end of a command is used to put commands into background. This is actually a standard syntax specified by POSIX standard:




                  Asynchronous Lists



                  If a command is terminated by the control operator
                  ( '&' ), the shell shall execute the command
                  asynchronously in a subshell. This means that the shell shall not wait
                  for the command to finish before executing the next command.



                  The format for running a command in the background is:



                  command1 & [command2 & ... ]




                  From the definition you can see that & also serves as command terminator for lists of commands, much like ; does. In your specific example, pyprogramm >> /dev/null 2>&1 & there is only one command in the list.



                  Sequential ; lists vs asynchronous & lists



                  More generally,



                  echo Hello ; echo World ;


                  and



                  echo Hello & echo World &


                  are two examples of lists terminated by the ; and & operators, with the difference that & terminated list will hide the output by redirecting output to /dev/null if job control is enabled, and in fact that's exactly what the standard also states:




                  If job control is disabled (see set, -m), the standard input for an
                  asynchronous list, before any explicit redirections are performed,
                  shall be considered to be assigned to a file that has the same
                  properties as /dev/null. This shall not happen if job control is
                  enabled. In all cases, explicit redirection of standard input shall
                  override this activity.




                  Thus, in the specific example redirecting >> /dev/null may be unnecessary, if job control is enabled by the shell.



                  Note also, that from the definition we mentioned earlier, & executes commands in subshell. By contrast, the ; terminated list is executed in current shell. There's also difference in exit statuses. For & the standard says:




                  The exit status of an asynchronous list shall be zero.




                  This is significant when you want to put multiple commands in background. When you write a script or command you will have to chose commands for which you don't care if they failed or not, or you will have to find a way to handle the non-zero ( error ) exit status. In your specific example, pyprogramm >> /dev/null 2>&1 & running in background should have some way of indicating if it failed or not, however judging that you use 2>&1 you are hiding error output by redirecting, and you probably assume the script should not fail.



                  By contrast, ; exit status is defined as:




                  The exit status of a sequential list shall be the exit status of the
                  last command in the list.




                  Again, this has implications on how you write a sequential list of commands in command-line and how you want things to be handled if some of the commands in the list failed.





                  The fact that this is POSIX definition means that all Bourne-like shells, meaning bash, dash, and ksh must support it.






                  share|improve this answer














                  What is the & terminator ?



                  The trailing & operator at the end of a command is used to put commands into background. This is actually a standard syntax specified by POSIX standard:




                  Asynchronous Lists



                  If a command is terminated by the control operator
                  ( '&' ), the shell shall execute the command
                  asynchronously in a subshell. This means that the shell shall not wait
                  for the command to finish before executing the next command.



                  The format for running a command in the background is:



                  command1 & [command2 & ... ]




                  From the definition you can see that & also serves as command terminator for lists of commands, much like ; does. In your specific example, pyprogramm >> /dev/null 2>&1 & there is only one command in the list.



                  Sequential ; lists vs asynchronous & lists



                  More generally,



                  echo Hello ; echo World ;


                  and



                  echo Hello & echo World &


                  are two examples of lists terminated by the ; and & operators, with the difference that & terminated list will hide the output by redirecting output to /dev/null if job control is enabled, and in fact that's exactly what the standard also states:




                  If job control is disabled (see set, -m), the standard input for an
                  asynchronous list, before any explicit redirections are performed,
                  shall be considered to be assigned to a file that has the same
                  properties as /dev/null. This shall not happen if job control is
                  enabled. In all cases, explicit redirection of standard input shall
                  override this activity.




                  Thus, in the specific example redirecting >> /dev/null may be unnecessary, if job control is enabled by the shell.



                  Note also, that from the definition we mentioned earlier, & executes commands in subshell. By contrast, the ; terminated list is executed in current shell. There's also difference in exit statuses. For & the standard says:




                  The exit status of an asynchronous list shall be zero.




                  This is significant when you want to put multiple commands in background. When you write a script or command you will have to chose commands for which you don't care if they failed or not, or you will have to find a way to handle the non-zero ( error ) exit status. In your specific example, pyprogramm >> /dev/null 2>&1 & running in background should have some way of indicating if it failed or not, however judging that you use 2>&1 you are hiding error output by redirecting, and you probably assume the script should not fail.



                  By contrast, ; exit status is defined as:




                  The exit status of a sequential list shall be the exit status of the
                  last command in the list.




                  Again, this has implications on how you write a sequential list of commands in command-line and how you want things to be handled if some of the commands in the list failed.





                  The fact that this is POSIX definition means that all Bourne-like shells, meaning bash, dash, and ksh must support it.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 mins ago

























                  answered 21 mins ago









                  Sergiy Kolodyazhnyy

                  69.7k9144306




                  69.7k9144306






























                      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%2f1107124%2fat-the-end-of-command%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

                      What visual should I use to simply compare current year value vs last year in Power BI desktop

                      Alexandru Averescu

                      Trompette piccolo