3

I have written a simple bash script:

#!/bin/bash
echo "hi" > log
exit 0

made it executable and its successfully running. I edited my rc.local to the following:

#!/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.

/home/katph/test.sh 

exit 0

rc.local is executable:

/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug  1 13:19 /etc/rc.local

What's working:

1.I directly put echo "hi" > /home/katph/log in rc.local, it works fine.Meaning rc.local runs at startup.

2.If I manually run rc.local with the script, log file is created correctly.

Any suggestion? I'm running Kubuntu14.04.

1
  • If you run bash -x /etc/rc.local, do you see any action? Aug 1, 2015 at 8:38

1 Answer 1

6

Replace

log

by an absolute path

/home/katph/log

E.G.

#!/bin/bash
echo "hi" > /home/katph/log
exit 0
0

You must log in to answer this question.

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