1

I would like some help getting a script to run on shutdown and restart.

Following advice I found online, I created the script and placed it in /etc/rc0.d and /etc/rc6.d.

Unfortunately, the scripts are not running and when I run Aptitude, I see the following error appear:

insserv: warning: script is corrupt or invalid: /etc/init.d/../rc0.d/K99-CreateSuccessfulPowerOffFile
insserv: warning: script is corrupt or invalid: /etc/init.d/../rc6.d/K99-CreateSuccessfulPowerOffFile

Here are the contents of the script:

#!/bin/sh
echo success > /etc/poweroffsuccess.txt
exit 0

And here are the permissions:

user@hostname:~$ ls -l /etc/rc0.d/K9*
-rwxrwxrwx 1 root root 58 Sep 24 11:11 /etc/rc0.d/K99-CreateSuccessfulPowerOffFile

user@hostname:~$ ls -l /etc/rc6.d/K9*
-rwxrwxrwx 1 root root 50 Aug 18 21:09 /etc/rc6.d/K99-CreateSuccessfulPowerOffFile
XJDHDR
  • 263

1 Answers1

0

If you read /etc/rc0.d/README, you'll see that you're not following the pattern. First, your script should be in /etc/init.d, and there should be a symbolic link to it (created with the ln command) in /etc/rc0.d or /etc/rc6.d. Also, the script should have a particular header as described in /etc/init.d/README. All the scripts in my /etc/init.d are owned by root; I'm not sure if that's a requirement, but it couldn't hurt. (The chown command is used to change ownership of a file.)

rclocher3
  • 779
  • 8
  • 19