5

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 ]
then
if [ -f /resize2 ]
then
sh /resize2
else
sh /resize
fi
fi

/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)

2
  • 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? Commented Jul 12, 2011 at 20:35
  • edited question with whole content of rc.content
    – genesis
    Commented Jul 12, 2011 at 20:37

1 Answer 1

9

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.

1
  • "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
    Commented Jul 12, 2011 at 20:47

You must log in to answer this question.

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