3

I'm executing a script on Ubuntu 14.04.1 LTS when the server is stopping But I would like to execute it only on shutdown behavior, not whendoing a reboot.

I tried to get the value with $1but for reboot or shutdown, but it always sending a stop message

The script I'm currently running:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          shutdown
# Required-Start:    
# Required-Stop:     sendsigs
# Default-Start:
# Default-Stop:      0 6
# Short-Description: shutdown
# Description: 
### END INIT INFO

shutdown_script.sh

exit 0

And run by sudo update-rc.d shutdown_job start 19 0 6 .

leo
  • 33

1 Answers1

3

Try putting the script in different runlevels.

/etc/rc0.d - While system shuts down.

/etc/rcS.d - While system boots

/etc/rc1.d - Working as singel user (user specific on login)

/etc/rc2.d - Working as multiple users

/etc/rc3.d bis /etc/rc5.d - not used in ubuntu

/etc/rc6.d - While system restarts
FRED99
  • 109