rc.local - 并非所有命令都被执行

rc.local - 并非所有命令都被执行

我的 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

但 nor/tmp/cooks/tmp/cookdir/tmp/xhprof均未创建(在系统启动时)。我在用着Debian GNU/Linux 6.0 squeeze (VPS)

答案1

该脚本以 开头#!/bin/sh -e。该-e选项意味着如果任何命令返回非零状态,shell 将退出。其中一个命令可能失败。也许/resizeor/resize2返回非零,或者也许/etc/rc是 or iptables-restore。将 shebang 行更改为#!/bin/sh -ex并运行脚本;您将看到它执行的命令的踪迹。

如果您发现其中一个命令在应该成功时返回非零,请修复该问题。如果您发现其中一个命令合法返回非零,请|| true在其后面添加。如果您发现您不关心任何命令的返回状态,请删除-e.

相关内容