Run script with rc.local: script works, but not at boot

前端 未结 16 1231
失恋的感觉
失恋的感觉 2020-12-02 07:38

I have a node.js script which need to start at boot and run under the www-data user. During development I always started the script with:

su www-dat         


        
16条回答
  •  暖寄归人
    2020-12-02 07:46

    1 Do not recommend using root to run the apps such as node app.

    Well you can do it but may catch more exceptions.

    2 The rc.local normally runs as root user.

    So if the your script should runs as another user such as www U should make sure the PATH and other environment is ok.

    3 I find a easy way to run a service as a user:

    sudo -u www -i /the/path/of/your/script

    Please prefer the sudo manual~ -i [command] The -i (simulate initial login) option runs the shell specified by the password database entry of the target user as a loginshell...

提交回复
热议问题