Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sudo nohup nice <-- in what order?

Tags:

So I have a script that I want to run as root, without hangup and nicely. What order should I put the commands in?

sudo nohup nice foo.bash &

or

nohup nice sudo foo.bash &

etc.

I suspect it doesn't matter but would like some insight from those who really know.

like image 332
Jonah Braun Avatar asked Dec 08 '08 18:12

Jonah Braun


2 Answers

If negative niceness is desired, I would do: sudo nohup nice command because according to `info coreutils' nohup should preceed nice. If I want a negative nice value, sudo must come before, since only root is able to use negative nice values.

If positive niceness is desired, I would do simply: nohup nice sudo command This ensures that nohup and nice are not run with root privileges.

like image 133
Felipe Alvarez Avatar answered Oct 06 '22 18:10

Felipe Alvarez


sudo may not respect niceness. At least, it doesn't on my machine (Ubuntu 9.04). Running this:

nice sudo nice sudo nice nice 

prints out 0 and 10. (Note that 'nice' with no command prints out the current niceness.)

like image 42
Adam Crume Avatar answered Oct 06 '22 18:10

Adam Crume