Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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)

share|improve this question
    
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 Jul 12 '11 at 20:35
    
edited question with whole content of rc.content –  genesis Jul 12 '11 at 20:37
add comment

1 Answer 1

up vote 8 down vote accepted

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.

share|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
    
thanks a million, I had this problem too. –  c2h2 May 4 '12 at 4:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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