This is my rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd /root/server/srv/
./start_srv &
exit 0
When I execute
cd /root/server/srv/
./start_srv &
via terminal myself, it starts normally and everything works but when I try and do it through rc.local it wont start.
I know rc.local doesn't need sudo etc. I tried executing rc.local myself through terminal and I get the error: "Can't CD to..."
What am I doing wrong?
ls -ld /root: drwx------ 4 root root 4096
,
ls -ld /root/server: drwxr-xr-x 3 root root 4096
,
ls -ld /root/server/srv/start_srv: -rwxr-x--x 1 500 500 468420
ls -ld /root/server/srv: drwxrwxrwx 2 500 500 4096
ls -ld /root
,ls -ld /root/server/
,ls -ld /root/server/srv
andls -ld /root/server/srv/start_srv
. Also the complete error when running/etc/rc.local
by hand could be useful. – Rmano Jul 31 '14 at 09:57ls -ld /root/server/srv
... – Rmano Jul 31 '14 at 11:00/etc/rc.local/
by hand? With which user you do that? Which user is the one with UID=500 which seems not to be recognized by the system? ---- and please, add the info on the question, it is almost unreadable in the comments. – Rmano Jul 31 '14 at 11:36cd
is not an executable, but a command for the shell. I am not sure, but maybe you can't run it viarc.local
. Why don't you just call/root/server/srv/start_srv &
instead? – Andrea Lazzarotto Jul 31 '14 at 11:42cd
works perfectly in scripts. And maybe the script need to be started with the current directory set. I would really do a(cd ... && ./start_script ) &
to use a subshell and not change the CWD globally, but this is nitpicking... – Rmano Jul 31 '14 at 11:48