Why can't I `nice` a command group?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












[fakename]$ nice yes a>/dev/null &
[1] 26475
[fakename]$ ps -p 26475 -o nice,pid
NI PID
10 26475
[fakename]$ nice yes a>/dev/null; &
-bash: syntax error near unexpected token `}'


Is there a way to nice a command group?



I am aware of one: to execute the command group as normal, put it in the background by appending an ampersand, and use renice on the command group. However, is there a way to accomplish the same thing with nice?



Also, why exactly is it giving me this error? Is it because nice is not a shell keyword, and thus must follow standard bash argument parsing rules?










share|improve this question

























    up vote
    -1
    down vote

    favorite












    [fakename]$ nice yes a>/dev/null &
    [1] 26475
    [fakename]$ ps -p 26475 -o nice,pid
    NI PID
    10 26475
    [fakename]$ nice yes a>/dev/null; &
    -bash: syntax error near unexpected token `}'


    Is there a way to nice a command group?



    I am aware of one: to execute the command group as normal, put it in the background by appending an ampersand, and use renice on the command group. However, is there a way to accomplish the same thing with nice?



    Also, why exactly is it giving me this error? Is it because nice is not a shell keyword, and thus must follow standard bash argument parsing rules?










    share|improve this question























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      [fakename]$ nice yes a>/dev/null &
      [1] 26475
      [fakename]$ ps -p 26475 -o nice,pid
      NI PID
      10 26475
      [fakename]$ nice yes a>/dev/null; &
      -bash: syntax error near unexpected token `}'


      Is there a way to nice a command group?



      I am aware of one: to execute the command group as normal, put it in the background by appending an ampersand, and use renice on the command group. However, is there a way to accomplish the same thing with nice?



      Also, why exactly is it giving me this error? Is it because nice is not a shell keyword, and thus must follow standard bash argument parsing rules?










      share|improve this question













      [fakename]$ nice yes a>/dev/null &
      [1] 26475
      [fakename]$ ps -p 26475 -o nice,pid
      NI PID
      10 26475
      [fakename]$ nice yes a>/dev/null; &
      -bash: syntax error near unexpected token `}'


      Is there a way to nice a command group?



      I am aware of one: to execute the command group as normal, put it in the background by appending an ampersand, and use renice on the command group. However, is there a way to accomplish the same thing with nice?



      Also, why exactly is it giving me this error? Is it because nice is not a shell keyword, and thus must follow standard bash argument parsing rules?







      nice






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 10 at 15:40









      extremeaxe5

      21916




      21916




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument.



          There is only on case where several shells did what you like to see. This is the time command that also exists as reserved word in some shells.






          share|improve this answer



























            up vote
            0
            down vote













            The nice utility takes as its operand another utility (possibly with arguments). It does not take a subshell or a compound command.



            To run a compound command with nice, use a child shell:



            nice sh -c 'mycommand; somethingelse; while [ something ]; do ...; done'


            See also:




            • The POSIX documentation of nice.


            • man nice on your system.





            share|improve this answer




















              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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              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%2f461835%2fwhy-cant-i-nice-a-command-group%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote



              accepted










              The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument.



              There is only on case where several shells did what you like to see. This is the time command that also exists as reserved word in some shells.






              share|improve this answer
























                up vote
                1
                down vote



                accepted










                The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument.



                There is only on case where several shells did what you like to see. This is the time command that also exists as reserved word in some shells.






                share|improve this answer






















                  up vote
                  1
                  down vote



                  accepted







                  up vote
                  1
                  down vote



                  accepted






                  The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument.



                  There is only on case where several shells did what you like to see. This is the time command that also exists as reserved word in some shells.






                  share|improve this answer












                  The way you like to use nice would require that nice is a reserved word in the shell but it is just a normal command that takes another simple command as an argument.



                  There is only on case where several shells did what you like to see. This is the time command that also exists as reserved word in some shells.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 10 at 15:51









                  schily

                  9,62131437




                  9,62131437






















                      up vote
                      0
                      down vote













                      The nice utility takes as its operand another utility (possibly with arguments). It does not take a subshell or a compound command.



                      To run a compound command with nice, use a child shell:



                      nice sh -c 'mycommand; somethingelse; while [ something ]; do ...; done'


                      See also:




                      • The POSIX documentation of nice.


                      • man nice on your system.





                      share|improve this answer
























                        up vote
                        0
                        down vote













                        The nice utility takes as its operand another utility (possibly with arguments). It does not take a subshell or a compound command.



                        To run a compound command with nice, use a child shell:



                        nice sh -c 'mycommand; somethingelse; while [ something ]; do ...; done'


                        See also:




                        • The POSIX documentation of nice.


                        • man nice on your system.





                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          The nice utility takes as its operand another utility (possibly with arguments). It does not take a subshell or a compound command.



                          To run a compound command with nice, use a child shell:



                          nice sh -c 'mycommand; somethingelse; while [ something ]; do ...; done'


                          See also:




                          • The POSIX documentation of nice.


                          • man nice on your system.





                          share|improve this answer












                          The nice utility takes as its operand another utility (possibly with arguments). It does not take a subshell or a compound command.



                          To run a compound command with nice, use a child shell:



                          nice sh -c 'mycommand; somethingelse; while [ something ]; do ...; done'


                          See also:




                          • The POSIX documentation of nice.


                          • man nice on your system.






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 10 at 15:46









                          Kusalananda

                          106k14209327




                          106k14209327



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f461835%2fwhy-cant-i-nice-a-command-group%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              Peggy Mitchell

                              Palaiologos

                              The Forum (Inglewood, California)