I have following lines in my rc.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.

if [ -f /resize ]
if [ -f /resize2 ]
sh /resize2
sh /resize

/etc/rc --foreground
/sbin/iptables-restore /etc/iptables
mkdir /tmp/cooks
mkdir /tmp/cook
chmod 777 /tmp/cook
chmod 777 /tmp/cooks
mkdir /tmp/xhprof
chmod 777 /tmp/xhprof

exit 0

but neither /tmp/cooks nor /tmp/cook nor /tmp/xhprof dir was not created (on system startup). I'm using Debian GNU/Linux 6.0 squeeze (VPS)

  • Is that the whole content of the file? There should be a #!/bin/sh line at the top. I notice Debian has #!/bin/sh -e by default and no /etc/rc, so the first line would fail and the script would exit. Is that what's happening? – Gilles 'SO- stop being evil' Jul 12 '11 at 20:35
  • edited question with whole content of rc.content – genesis Jul 12 '11 at 20:37

The script begins with #!/bin/sh -e. The -e option means that the shell will exit if any command returns a nonzero status. It's likely that one of the commands is failing. Perhaps /resize or /resize2 is returning nonzero, or perhaps /etc/rc is, or iptables-restore. Change the shebang line to #!/bin/sh -ex and run the script; you'll see a trace of the commands it executes.

If you find that one of the commands is returning nonzero when it should have succeeded, fix that. If you find that one of the commands is returning nonzero legitimately, add || true after it. If you find that you don't care about the return status of any of the commands, remove the -e.

| improve this answer | |
  • "vm645:/var/log/apache2# /etc/init.d/rc.local start + /sbin/iptables-restore /etc/iptables + mkdir /tmp/cooks mkdir: adresář „/tmp/cooks“ nelze vytvořit: Soubor již existuje vm645:/var/log/apache2# " THANK YOU ! – genesis Jul 12 '11 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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