Bash – sudo nohup nice <-- in what order


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 &


nohup nice sudo foo.bash &


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

Best Solution

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.