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
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.
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.
I had the same problem (on CentOS 7) and I fixed it by giving execute permissions to /etc/local:
chmod +x /etc/rc.local
I ended up with upstart, which works fine.
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.
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.