1

I'm running Raspbian GNU/Linux 8 (jessie) on Raspberry Pi rev2. I have written a python app running in background collecting some data. The app itself works fine. But I need to make it run at boot up. I followed this instruction to prepare a valid /etc/init.d/... script. Looks like this:

#! /bin/sh
# /etc/init.d/templogger

### BEGIN INIT INFO
# Provides:          templogger
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start a program at boot
# Description:       A simple script from www.stuffaboutcode.com which will start / stop a program a boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting templogger"
    # run application you want to start
    /home/pi/templogger/templogger.py &
    ;;
  stop)
    echo "Stopping templogger"
    # kill application you want to stop
    killall -15 templogger.py  &
    ;;
  *)
    echo "Usage: /etc/init.d/templogger {start|stop}"
    exit 1
    ;;
esac

exit 0

When I run try to "start" the service like this:

sudo /etc/init.d/templogger start

... it works as expected - the service is really running properly so I assume the init.d script can run my app - no permission problems. When I try to "stop" the service:

sudo /etc/init.d/templogger stop

... it stops nicely.

The next step according to 1 is to "register" the script to run at start-up:

sudo update-rc.d templogger defaults

This command does not produce any output. However, when I check the /etc/rcX.d/ there are symlinks like supposed to be: lrwxrwxrwx 1 root root 20 lut 15 21:27 S03templogger -> ../init.d/templogger When I

sudo update-rc.d templogger remove

... the symlinks dissapear. So I guess the "update-rc" is doing it's job. The problem is when I try to run it via "service" interface:

sudo service templogger start

... nothing happens. App is not starting according to it's internal logs nor there is any output from "service" command. Also I would expect the app is run at start-up, but it is not. I searched for post related to service start/stop interface but all I found is related to specific services people struggle to run and I didn't found similar case. Also I considered switching to Upstart but... well, no. Also tried putting it in crontab as @reboot /home/pi/templogger/templogger.py & but that approach didn't work either. What have I missed?

M.K.
  • 89
  • 3
  • it's a visual basic script ? Which .bin can run srcript ? `python /home/pi/templogger/templogger.py &` And a point `how to keep alive your main app ?` – dsgdfg Feb 16 '16 at 15:59
  • It its a python script with a shebang statement `#!/usr/bin/python3.4`. The main app invokes 2 threads (one polling data from sensor, and one collecting this data to sqlite). Main app waits for threads to end which is infinite, or until there is SIGTERM or SIGINT. Then threads end their loops and main exits. I can see when the app is running - there is a flow of data in sqlite db. – M.K. Feb 16 '16 at 20:46

0 Answers0