-1
[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?

1

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.

0

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.