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?

  • 2
    the sh-bang line of /home/myusername/myscript.sh is suspect; can you post it?
    – Jeff Schaller
    Commented Jan 29, 2018 at 20:31
  • 7
    Is /home mounted at boot-time when rc.local is executing?
    – DopeGhoti
    Commented Jan 29, 2018 at 20:34
  • If by sh-bang line you mean the first line, this is it: #!/bin/bash
    – P. Mensch
    Commented Jan 30, 2018 at 0:07
  • How do I determine when /home is mounted?
    – P. Mensch
    Commented Jan 30, 2018 at 0:08
  • 1
    Did you by any chance write the script on a Windows system (so that it's a DOS text file)? If so, the #! line would definitely point to a nonexistent interpreter, due to the extra carriage return character at the end of each line.
    – Kusalananda
    Commented Dec 15, 2020 at 22:15

1 Answer 1


If you've got rights to change rc.local you're also able to place your script into /usr/local/bin, or /usr/bin, or even /bin if necessary, which are more likely to be available at boot time than /home, which may be located on a different drive or partition.

Also read more about the usage of rc.local to make sure it's the right place to do what you intend. And be careful of what you do in that script, as it may mess up your boot process.

  • /usr/local/bin did not work. Same problem, rc.local can't find the file.
    – P. Mensch
    Commented Jan 30, 2018 at 23:06
  • Also, I'm just trying to get a simple script to run on startup and it seemed that using rc.local was the simplest way to do so. I was in fact following the directions of a guide.
    – P. Mensch
    Commented Jan 30, 2018 at 23:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .