这是我在/ etc / init /
中的配置文件start on (local-filesystems and net-device-up IFACE=eth0)
stop on shutdown
# Automatically restart service
respawn
respawn limit 99 5
script
mkdir /var/log/my_task
<my task which log to /var/log/my_task>
end script
问题是服务每次都会尝试创建文件夹。 仅当文件夹不存在时如何运行命令?
答案 0 :(得分:0)
此代码适用于您:
start on local-filesystems
stop on runlevel [!2345]
respawn limit 99 5
script
if [ ! -e /var/log/my_task ]; then
/bin/mkdir /var/log/my_task
fi
end script