Since /etc/rc.local
is executed at the end of each multiuser runlevel, it's not the correct place to add start scripts. I recommend to not use /etc/rc.local
in any way. It's a reclit for early *nix times. Instead of that, create a startup script in /etc/init.d/name
which accepts start
and stop
arguments to start or stop the deamon, process or the job:
#! /bin/sh
# /etc/init.d/name
#
case "$1" in
start)
echo "Starting name"
your_service --with --parameters
;;
stop)
echo "Stopping name"
kill your_service
;;
*)
echo "Usage: /etc/init.d/name {start|stop}"
exit 1
;;
esac
exit 0
Also there is a skeleton script in /etc/init.d/skeleton
for this.
After you created that scripts, set the permissons:
chmod 755 /etc/init.d/name
Now, add them to the boot seqence:
update-rc.d name defaults
This will create the necessary links in the /etc/rc*.d/
directories.
source
? – Anthon Aug 25 '15 at 13:03source
is needed cause I call a script in another script. – ArchiT3K Aug 25 '15 at 13:04When you call 'sh', you initiate a fork (sub-process) that runs a new session of /bin/sh, which is usually a symbolic link to bash. In this case, environment variables set by the sub-script would be dropped when the sub-script finishes.
– ArchiT3K Aug 25 '15 at 13:05source
is only necessary if you want to have the statements in the script to have effect in rc.local itself (ie. set variables, etc.). – Anthon Aug 25 '15 at 13:05