我已经创建了一个LSBized Init脚本,它在启动时运行一些脚本,然后在脚本被杀死或关闭时重新启动脚本 .
起初一切看起来都很好,但几分钟后init脚本停止,另一个脚本继续运行 .
我在/ var / log / syslog中收到此错误
Jun 9 14:53:49 debian systemd[1]: test.service start operation timed out. Terminating.
Jun 9 14:53:49 debian systemd[1]: Failed to start LSB: Start some script on boot and restarts it if it stops..
Jun 9 14:53:49 debian systemd[1]: Unit test.service entered failed state.
我的脚本看起来像这样:
#! /bin/sh
# /etc/init.d/test
#
### BEGIN INIT INFO
# Provides: $parentscript
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start some script on boot and restarts it if it stops.
# Description: Start some script on boot and restarts it if it stops.
### END INIT INFO
start() {
until /home/user/runthis; do
echo "Process crashed with exit code $?. Respawning.." >&2
sleep 1
done
}
# Carry out specific functions when asked to by the system
case "$1" in
start)
start
;;
stop)
echo "Stopping script test"
;;
*)
echo "Usage: /etc/init.d/test {start|stop}"
exit 1
;;
esac
exit 0
我尝试使用Debian 8.0 x64和x86,在这两种情况下都会发生同样的事情 .
有什么我做错了吗?或者还有其他方法可以达到相同的效果吗?谢谢!