1

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?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

1 Answers1

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.

Murphy
  • 2,649
  • /usr/local/bin did not work. Same problem, rc.local can't find the file. – P. Mensch Jan 30 '18 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 Jan 30 '18 at 23:07