3

I have created a bash script inside /etc/init.d on raspbian jessie - pixel. The script is as follow:

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)

What I need to do is:

  1. start forever on app.js: forever start app.js

  2. After the forever is started, run the python script simulation.py: python simulation.py

The problem is forever starts successfully but the python script doesn't run.

When I run the above script in terminal using ./auto_announce , the script works perfectly. But it isn't working perfectly on system boot.

What am I missing? Is there a way to log the output of the above script to find out what is causing the problem?

Thanks.

Biffen
  • 6,249
  • 6
  • 28
  • 36
  • 1
    Yes, there are ways to log. E.g. by adding some redirection in the script. But if you're using systemd I'd recommend writing a service instead, and you should get a lot of stuff for free, e.g. logging. – Biffen Feb 06 '17 at 08:06

1 Answers1

1

Probably forever start app.js takes sometime to execute,so put some sleep before executing python /home/pi/vehicle_anouncement_system/simulation.py. i.e. try (cd /home/pi/vehicle_anouncement_system/ && forever start app.js) && (sleep 20) && (python /home/pi/vehicle_anouncement_system/simulation.py)

xruptronics
  • 2,785
  • 3
  • 12
  • 17