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 found that because I was using a network-oriented command in my rc.local
, sometimes it would fail. I fixed this by putting sleep 3
at the top of my script. I don't know why but it seems when the script is run the network interfaces aren't properly configured or something, and this just allows some time for the DHCP server or something. I don't fully understand but I suppose you could give it a try.