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.

  • Releated (unix.stackexchange.com/questions/48973/…). – 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 unix.stackexchange.com/questions/170555/… 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 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 1 '14 at 16:08
-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!

  • Hey, due to the fact that the K scripts are run before the S scripts, starting a script in runlevel 0 has to be done in a K script (the last K script shuts down the system - after that nothing else will/can be executed ;)). So I configured my script in init.d as such that it will be executed if the parameter "stop" is used abd therefore the placement as K01 ... – Matthias Nov 29 '14 at 13:29
  • lrwxrwxrwx 1 root root 17 Nov 5 07:28 S00killall -> ../init.d/killall lrwxrwxrwx 1 root root 14 Nov 5 07:28 S01halt -> ../init.d/halt These are shutdown the system not last K. – Sepahrad Salour Nov 29 '14 at 13:33
  • Hey again, here is my content in /etc/rc0.d – Matthias Nov 29 '14 at 14:20
  • Sorry, new try: lrwxrwxrwx 1 root root 14 Nov 29 13:08 K10halt -> ../init.d/halt – Matthias Nov 29 '14 at 14:21
  • I think the differences between your system and mine are coming from the different distros. – Matthias Nov 29 '14 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.