2

I made a script with following LSB header

#! /bin/sh
### BEGIN INIT INFO
# Provides:          updateservice
# Required-Start:    $local_fs $time $network $named $syslog
# Required-Stop:     $local_fs $time $network $named $syslog
# Default-Start:
# Default-Stop:      0
# Short-Description: Update Service
# Description:       This script is meant to update and upgrade
#                    the system. It uses apt-get.
### END INIT INFO

placed it in /etc/init.d and created the links with update-rc.d and got the one I wanted to have

 lrwxrwxrwx 1 root root 19 Nov 29 13:08 /etc/rc0.d/K01update.sh -> ../init.d/update.sh

.... but: The script ist not executed at shutdown. Why?

Running /etc/init.d/update.sh stop manuallly does exactly what I want, but it's not executed when shutting down. And, just as a fun fact, same script and configuration on a raspberry pi works just as expected.

You guys are the experts... anybody any idea?

PS: uname -a output:

Linux d3bi4n 3.16.0-4-amd64 #1 SMP Debian 3.16.7-2 (2014-11-06) x86_64 GNU/Linux

My init system is Systemd.

Matthias
  • 1,053
  • Releated (http://unix.stackexchange.com/questions/48973/execute-a-command-before-shutdown). – DisplayName Nov 29 '14 at 12:48
  • @DisplayName thanks, but I already saw this post and it does not fix my problem – Matthias Nov 29 '14 at 13:00
  • 1
    Given http://unix.stackexchange.com/questions/170555/why-is-my-debian-jessie-always-in-runlevel-5 it turns out that you're running Systemd. So do you want to know how to run a shutdown-time script with Systemd, or do you want to switch back to SysVinit? – Gilles 'SO- stop being evil' Nov 30 '14 at 16:28
  • Hey @Gilles .. you are the man! Thanks for your post on the other question. I switched back to sysvinit for now. But I think about changing to systemd later (after doing some research). – Matthias Dec 01 '14 at 16:08

1 Answers1

-1

From your output :

lrwxrwxrwx 1 root root 19 Nov 29 13:08 /etc/rc0.d/K01update.sh -> ../init.d/update.sh

K in K01update.sh means killing process in 01th step when linux goes to zero runlevel! I don't have debian but as all of them are linux, In redhat linux you need to add a comment line like following to tell the chkconfig start or stop the service in these priorities!

# chkconfig: 2345 70 80

The first numbers are runlevels (2345), second one means starting priority (70), and the last one means stopping priority(80)!

But I have no idea about update-rc.d whether it need it or not!

Braiam
  • 35,991