Linux 脚本不';t手动启动(或启动时)(初始d)
我在运行tinkerOS,这是debian的发行版。但由于某些原因,在raspbian(也基于debian)上运行的cwhservice没有在tinkerOS上运行 该脚本位于/etc/init.d/中,名为cwhservice,systemctl deamon重载已完成,代码如下:Linux 脚本不';t手动启动(或启动时)(初始d),linux,shell,debian,init.d,lsb,Linux,Shell,Debian,Init.d,Lsb,我在运行tinkerOS,这是debian的发行版。但由于某些原因,在raspbian(也基于debian)上运行的cwhservice没有在tinkerOS上运行 该脚本位于/etc/init.d/中,名为cwhservice,systemctl deamon重载已完成,代码如下: #!/bin/sh ### BEGIN INIT INFO # Provides: CWH # Required-Start: $all # Required-Stop: # Default-St
#!/bin/sh
### BEGIN INIT INFO
# Provides: CWH
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts the CWH
# Description: Starts the CWH
### END INIT INFO
case "$1" in
start)
/opt/cwh/start.sh > /opt/cwh/log.scrout 2> /opt/cwh/log.screrr
;;
stop)
/opt/cwh/stop.sh
;;
restart)
/opt/cwh/stop.sh
/opt/cwh/start.sh
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
当我运行时:sudo服务cwhservice start
我得到以下错误:
Job for cwhservice.service failed because the control process exited with error code.
See "systemctl status cwhservice.service" and "journalctl -xe" for details.
systemctl状态cwhservice.service提供:
● cwhservice.service - LSB: Starts the CWH
Loaded: loaded (/etc/init.d/cwhservice; generated; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2017-08-24 13:36:22 UTC; 1min 21s ago
Docs: man:systemd-sysv-generator(8)
Process: 15431 ExecStart=/etc/init.d/cwhservice start (code=exited, status=203/EXEC)
Aug 24 13:36:22 linaro-alip systemd[1]: Failed to start LSB: Starts the CWH.
Aug 24 13:36:22 linaro-alip systemd[1]: cwhservice.service: Failed with result 'exit-code'.
因此,在处理了所有代码和值之后,我仍然无法使其正常工作,因此我尝试重新建模重新启动脚本,该脚本目前的结果如下:
#! /bin/sh
### BEGIN INIT INFO
# Provides: kaas2
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop: 6
# Short-Description: Execute the reboot command.
# Description:
### END INIT INFO
case "$1" in
start)
# No-op
/opt/cwh/start.sh
echo "foo" >&2
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
;;
status)
exit 0
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
sudo服务cwhservice start
不返回错误,只是不执行任何操作。但是由于某种奇怪的原因,sudo服务cwhservicer restart
实际上启动了start.sh脚本,但没有返回echo。。。所以我在这一点上完全迷失了方向,浪费了两天
关于如何创建一个deamon,我可以在引导时启动它并在debian上启动start.sh脚本,你有没有在tinkerOS上安装过
lsb release
?我刚刚检查过,它已经预安装了,Tinkboard版本是1.9,如果从终端运行,start.sh命令运行得很好。我知道我可能太晚了,但如果以后有人发现这一点,它可能会很有用。我有类似的问题,我正在故障排除了一段时间。当您手动启动init.d脚本(使用“开始”选项),然后通过其他方式终止(不使用“停止”选项)时,systemctl仍将服务报告为活动。在我的例子中,这意味着每个子序列的“start”命令实际上并没有再次运行脚本,因为服务仍在运行。运行“停止”然后再运行“启动”或“重启”命令将导致再次运行脚本。您是否在tinkerOS上安装了lsb release
?我刚刚检查过,它已经预安装了。Tinkboard版本为1.9,如果从终端运行,start.sh命令运行正常。我知道我可能太晚了,但如果以后有人发现这一点,它可能会很有用。我有类似的问题,我正在故障排除了一段时间。当您手动启动init.d脚本(使用“开始”选项),然后通过其他方式终止(不使用“停止”选项)时,systemctl仍将服务报告为活动。在我的例子中,这意味着每个子序列的“start”命令实际上并没有再次运行脚本,因为服务仍在运行。运行“停止”然后“启动”或“重新启动”命令将导致脚本重新生成。