1

Help please. I can't figure out the syntax to nice a for loop on the command line.

This is my best guess:

$ nice -n 17 { for _ in {1..2}; do echo howdy; done; }
bash: syntax error near unexpected token `do'

But obviously, that's not correct.

timmer
  • 263
  • 1
  • 3
  • 9

1 Answers1

8

nice is per process, and can not operate on individual shell statements.

You can either start a new, nice bash instance:

nice -n 17 bash -c 'for _ in {1..2}; do echo howdy; done;'

Or fork one and renice that:

( 
  renice -n 17 "$BASHPID"
  for _ in {1..2}; do echo howdy; done;
)
that other guy
  • 116,971
  • 11
  • 170
  • 194