sudo nohup nice <— in what order?

后端 未结 6 1546
南旧
南旧 2021-02-12 13:51

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

noh

6条回答
  •  终归单人心
    2021-02-12 14:07

    Disagree with other answers. I recommend:

    sudo nohup nice foo.sh

    I have observed nohup sudo #fail -- ie nohup is not always transferred to sudo'd sub-sub-processes (this was for certain /etc/init.d scripts on Ubuntu which delegated to yet other scripts). Not sure why, certainly surprising, but was the case and took a good wee while to debug.

    (I note others report niceness not being passed through, so seems best to put it last ... although if in doubt on your OS put nice earlier, because nice not taking effect is usually less of a problem than nohup not taking effect!)

    Note that sudo nohup leaves nohup.out owned by root, also as has been mentioned, but that's fixed with a:

    sudo nohup nice foo.sh >> /tmp/foo.stdout.log 2>> /tmp/foo.stderr.log

提交回复
热议问题