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

前端 未结 16 1043
失恋的感觉
失恋的感觉 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:47

    I am using CentOS 7.

    $ cd  /etc/profile.d
    
    $ vim yourstuffs.sh
    

    Type the following into the yourstuffs.sh script.

    type whatever you want here to execute

    export LD_LIBRARY_PATH=/usr/local/cuda-7.0/lib64:$LD_LIBRARY_PATH
    

    Save and reboot the OS.

    0 讨论(0)
  • 2020-12-02 07:54

    I got my script to work by editing /etc/rc.local then issuing the following 3 commands.

    sudo mv /filename /etc/init.d/
    sudo chmod +x /etc/init.d/filename 
    sudo update-rc.d filename defaults
    

    Now the script works at boot.

    0 讨论(0)
  • 2020-12-02 07:55

    I had the same problem (on CentOS 7) and I fixed it by giving execute permissions to /etc/local:

    chmod +x /etc/rc.local
    
    0 讨论(0)
  • 2020-12-02 07:56

    I ended up with upstart, which works fine.

    0 讨论(0)
  • 2020-12-02 07:56

    In Ubuntu I noticed there are 2 files. The real one is /etc/init.d/rc.local; it seems the other /etc/rc.local is bogus?

    Once I modified the correct one (/etc/init.d/rc.local) it did execute just as expected.

    0 讨论(0)
  • 2020-12-02 08:00

    rc.local only runs on startup. If you reboot and want the script to execute, it needs to go into the rc.0 file starting with the K99 prefix.

    0 讨论(0)
提交回复
热议问题