2017-02-06 92 views
3

我已经raspbian杰西创建内部/etc/init.d中 bash脚本 - 像素。该脚本如下:bash脚本不执行按预期在系统启动

auto_announce

#! /bin/bash 
#/etc/init.d/auto_announce 

### BEGIN INIT INFO 
# Provides:   auto_announce 
# Required-Start: $remote_fs $syslog 
# Required-Stop:  $remote_fs $syslog 
# Default-Start:  2 3 4 5 
# Default-Stop:  0 1 6 
# Short-Description: Start daemon at boot time 
# Description:  Enable service provided by daemon. 
### END INIT INFO 


amixer cset numid=3 1 
(cd /home/pi/vehicle_anouncement_system/ && forever start app.js) && (python /home/pi/vehicle_anouncement_system/simulation.py) 

我需要做的是:

  1. 开始永远在app.js:forever start app.js

  2. 后永远的启动,运行python脚本simulation.py:python simulation.py

问题是永远成功开始,但python脚本不运行

当我在终端使用./auto_announce运行上述脚本时,该脚本完美地工作。但是它在系统启动时并不完美。

我缺少什么?是否有一个登录上述脚本的输出找出是什么原因造成的问题呢?

谢谢。

+1

是的,有办法来登录。例如。通过在脚本中添加一些重定向。但是如果你使用的是systemd,我建议你写一个服务,而且你应该得到很多免费的东西,例如日志记录。 – Biffen

回答

1

可能forever start app.js需要一段时间才能执行,因此在执行python /home/pi/vehicle_anouncement_system/simulation.py之前进行一些睡眠。 即尝试(cd /home/pi/vehicle_anouncement_system/ && forever start app.js) && (sleep 20) && (python /home/pi/vehicle_anouncement_system/simulation.py)

+0

,对于启动工作,但它为什么不睡觉工作时,我直接在终端上运行。 –