2

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.

  • If you run bash -x /etc/rc.local, do you see any action? – Karl Richter Aug 1 '15 at 8:38
5

Replace

log

by an absolute path

/home/katph/log

E.G.

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.