0

I have made an LSBized Init Script, that runs some script at boot, and than restarts the script if it has been killed or closed.

At first everything looks fine, but after few minutes the init script stops, the other script keeps running.

I get this error in /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.

My script looks like this:

#! /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

I tried on Debian 8.0 x64 and x86, same thing happens in both cases.

Is there something I am doing wrong? Or is there any other way to achieve the same result? Thanks!

Jure Špik
  • 331
  • 2
  • 11
  • 2
    I expect systemd isn't expecting your main script process to loop forever and is expecting it to spawn something that runs in the background and then quit. Since systemd is in use you should probably write a service script for your process and then configure systemd to handle restarting it instead of doing it yourself. – Etan Reisner Jun 09 '15 at 13:35
  • Thanks Etan, thats exacty what the problem was :) – Jure Špik Jun 12 '15 at 06:23

0 Answers0