I am trying to get my script to run on startup. I am using Ubuntu Server 16.04.
Here are the exact contents of /etc/r.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.
sleep 1
/home/myusername/myscript.sh 15 &
exit 0
Here's relevant output from /var/log/syslog, when starting up:
rc.local[1157]: /etc/rc.local: 15: /etc/rc.local: /home/myusername/myscript.sh: not found
The script in question has all needed permissions AFAICT.
myusername@myserver:~$ ls -l /home/myusername/myscript.sh
-rwxr-xr-x 1 root root 199 Jan 23 09:19 /myusername/myscript.sh
When manually executing rc.local or my script, it runs fine.
What could be some reasons that rc.local can't access the file on startup?
/home
mounted at boot-time whenrc.local
is executing? – DopeGhoti Jan 29 '18 at 20:34#!/bin/bash
– P. Mensch Jan 30 '18 at 00:07/home
is mounted? – P. Mensch Jan 30 '18 at 00:08#!
line would definitely point to a nonexistent interpreter, due to the extra carriage return character at the end of each line. – Kusalananda Dec 15 '20 at 22:15/usr/local/bin
. It's available earlier in the system startup process. To see how your system starts, page throughsudo journalctl -b 0
– waltinator Aug 22 '21 at 18:55