One-liner to execute a process in a current directory with no output and disown it?












2















I'm trying to do something fairly simple:



$ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
-bash: syntax error near unexpected token `;'


How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?










share|improve this question





























    2















    I'm trying to do something fairly simple:



    $ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
    -bash: syntax error near unexpected token `;'


    How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?










    share|improve this question



























      2












      2








      2








      I'm trying to do something fairly simple:



      $ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
      -bash: syntax error near unexpected token `;'


      How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?










      share|improve this question
















      I'm trying to do something fairly simple:



      $ ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & ; disown $! )
      -bash: syntax error near unexpected token `;'


      How can I bust out a one-liner to, in a sub-shell, execute a given script from a given folder, nulling the output, and sending it to the background?







      bash disown






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 21 '16 at 19:01









      lesmana

      14.5k115873




      14.5k115873










      asked Jan 24 '13 at 1:32









      Naftuli KayNaftuli Kay

      12.5k56159256




      12.5k56159256






















          3 Answers
          3






          active

          oldest

          votes


















          10














          The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:



          ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )





          share|improve this answer
























          • I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

            – akskap
            Apr 30 '18 at 13:24



















          1














          The nohup utility was designed for pretty much what you're looking for:



          Usage: nohup COMMAND [ARG]...
          or: nohup OPTION
          Run COMMAND, ignoring hangup signals.

          If standard input is a terminal, redirect it from /dev/null.
          If standard output is a terminal, append output to 'nohup.out' if possible,
          '$HOME/nohup.out' otherwise.
          If standard error is a terminal, redirect it to standard output.
          To save output to FILE, use 'nohup COMMAND > FILE'.





          share|improve this answer































            0














            This worked for me:



            $(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &





            share|improve this answer








            New contributor




            Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




















              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "106"
              };
              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: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              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%2funix.stackexchange.com%2fquestions%2f62346%2fone-liner-to-execute-a-process-in-a-current-directory-with-no-output-and-disown%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









              10














              The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:



              ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )





              share|improve this answer
























              • I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

                – akskap
                Apr 30 '18 at 13:24
















              10














              The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:



              ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )





              share|improve this answer
























              • I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

                – akskap
                Apr 30 '18 at 13:24














              10












              10








              10







              The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:



              ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )





              share|improve this answer













              The problem is that you are using both & and ; together. They are both command terminators, and can not be used at the same time. Here is your example fixed:



              ( cd /opt/myprogram && ./myprocess.sh >/dev/null 2>&1 & disown )






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jan 24 '13 at 1:54









              jordanmjordanm

              30.9k38695




              30.9k38695













              • I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

                – akskap
                Apr 30 '18 at 13:24



















              • I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

                – akskap
                Apr 30 '18 at 13:24

















              I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

              – akskap
              Apr 30 '18 at 13:24





              I am trying a command on similar lines : bosh -e bosh -d service-fabrik ssh broker -c "tail -F /var/vcap/sys/log/service-fabrik-broker/service-fabrik-broker.log > /var/vcap/sys/log/service-fabrik-broker/error.log 2>&1 & disown" , but it doesn't seem to work. Any idea what could be wrong ? Thanks

              – akskap
              Apr 30 '18 at 13:24













              1














              The nohup utility was designed for pretty much what you're looking for:



              Usage: nohup COMMAND [ARG]...
              or: nohup OPTION
              Run COMMAND, ignoring hangup signals.

              If standard input is a terminal, redirect it from /dev/null.
              If standard output is a terminal, append output to 'nohup.out' if possible,
              '$HOME/nohup.out' otherwise.
              If standard error is a terminal, redirect it to standard output.
              To save output to FILE, use 'nohup COMMAND > FILE'.





              share|improve this answer




























                1














                The nohup utility was designed for pretty much what you're looking for:



                Usage: nohup COMMAND [ARG]...
                or: nohup OPTION
                Run COMMAND, ignoring hangup signals.

                If standard input is a terminal, redirect it from /dev/null.
                If standard output is a terminal, append output to 'nohup.out' if possible,
                '$HOME/nohup.out' otherwise.
                If standard error is a terminal, redirect it to standard output.
                To save output to FILE, use 'nohup COMMAND > FILE'.





                share|improve this answer


























                  1












                  1








                  1







                  The nohup utility was designed for pretty much what you're looking for:



                  Usage: nohup COMMAND [ARG]...
                  or: nohup OPTION
                  Run COMMAND, ignoring hangup signals.

                  If standard input is a terminal, redirect it from /dev/null.
                  If standard output is a terminal, append output to 'nohup.out' if possible,
                  '$HOME/nohup.out' otherwise.
                  If standard error is a terminal, redirect it to standard output.
                  To save output to FILE, use 'nohup COMMAND > FILE'.





                  share|improve this answer













                  The nohup utility was designed for pretty much what you're looking for:



                  Usage: nohup COMMAND [ARG]...
                  or: nohup OPTION
                  Run COMMAND, ignoring hangup signals.

                  If standard input is a terminal, redirect it from /dev/null.
                  If standard output is a terminal, append output to 'nohup.out' if possible,
                  '$HOME/nohup.out' otherwise.
                  If standard error is a terminal, redirect it to standard output.
                  To save output to FILE, use 'nohup COMMAND > FILE'.






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 24 '13 at 5:54









                  tylerltylerl

                  1,866816




                  1,866816























                      0














                      This worked for me:



                      $(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &





                      share|improve this answer








                      New contributor




                      Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.

























                        0














                        This worked for me:



                        $(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &





                        share|improve this answer








                        New contributor




                        Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.























                          0












                          0








                          0







                          This worked for me:



                          $(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &





                          share|improve this answer








                          New contributor




                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.










                          This worked for me:



                          $(cd /opt/myprogram && myprocess.sh 1>/dev/null 2>/dev/null &) &






                          share|improve this answer








                          New contributor




                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered 12 mins ago









                          UlysnepUlysnep

                          1




                          1




                          New contributor




                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Ulysnep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • 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%2funix.stackexchange.com%2fquestions%2f62346%2fone-liner-to-execute-a-process-in-a-current-directory-with-no-output-and-disown%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

                              CARDNET

                              Boot-repair Failure: Unable to locate package grub-common:i386

                              濃尾地震