Why does this shutdown script not work?

General support questions
Post Reply
pstein
Posts: 87
Joined: 2008/11/26 21:34:55

Why does this shutdown script not work?

Post by pstein » 2015/08/27 11:28:53

I want to execute a certain script (resp. some commands) always at shutdown time.

Acording to some recommendation I (as root) created a (new) script file

/etc/rc.d/init.d/local-shutdown

with (e.g.) the following simplified content:

#!/bin/bash
rm -rf /tmp/*

and made it executable for all.

... but it is never executed.

Why not?

Peter

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Re: Why does this shutdown script not work?

Post by gerald_clark » 2015/08/27 12:42:41

Better question:
Why do you think it should be?

pstein
Posts: 87
Joined: 2008/11/26 21:34:55

Re: Why does this shutdown script not work?

Post by pstein » 2015/08/27 13:08:06

Because I read it in a comment. Unfortunately I do not remember the exact web page.

So any other related suggestion?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Why does this shutdown script not work?

Post by TrevorH » 2015/08/29 22:37:35

There are better ways to clear /tmp at reboot - mainly making it tmpfs and then nothing on it survives a reboot. Or even creating its own LV and using /etc/crypttab with a random key so that it's reformatted every time you boot up.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

pstein
Posts: 87
Joined: 2008/11/26 21:34:55

Re: Why does this shutdown script not work?

Post by pstein » 2015/09/05 04:45:05

Maybe there are better ways for this particular command.

However it was a simplified example from me for a before-shotdown command.

There are other commands resp more complex script I want to perform just before I shutdown.

So I am searching for a general way where (in which file/folder) I can put commands to let them automatically execute at shutdown.

So where is the intended place for them?

User avatar
InitOrNot
Posts: 122
Joined: 2015/06/10 18:26:51

Re: Why does this shutdown script not work?

Post by InitOrNot » 2015/09/05 05:00:32

pstein wrote:I want to execute a certain script (resp. some commands) always at shutdown time.

Acording to some recommendation I (as root) created a (new) script file

/etc/rc.d/init.d/local-shutdown
I think you should make a symlink to that script from /etc/rc0.d/ and /etc/rc6.d/

Otherwise, you have the script but it is not invoked and shutdown or reboot.

Post Reply