2

I need to backup some files every time I shutdown a Red Hat Enterprise Linux 4. I thought about make it with a script in /etc/rc0.d but shutdown process should wait for my script to finish. So the only idea I have is to make the script run first of all and stop shutdown process, then at the end of the script run shutdown again. Can anyone tell me if there is any other better way to do this? Could work my own idea to make it?

10
  • I don't really get the problem. The server will wait for the script to finish. Otherwise shutdown would occur for all other scripts in rc6.d (which is reboot, by the way. shutdown is rc0.d) before they have completed, leading to broken mysql databases etc.
    – etagenklo
    Jul 25, 2013 at 9:59
  • Hi, My mistake rc6.d, i really mean rc0.d. About rc scripts it does not work for me. Maybe i´m doing wrong, but i put K01<name> script in rc0.d (linked from /etc/init.d/<name>) and it doesn´t work. The little script just try to make touch file after 120 seconds sleep. Are you sure shutdown process waits for all scripts in rc0.d?
    – Abraham
    Jul 25, 2013 at 10:39
  • Is your script exectutable (chmod +x)? What's the output of ls -la /etc/rc0.d/ ?
    – etagenklo
    Jul 25, 2013 at 10:56
  • Yes is executable.
    – Abraham
    Jul 25, 2013 at 10:59
  • Yes is executable. Output is: lrwxrwxrwx 1 root root 17 Apr 23 17:52 K00abcwait -> ../init.d/abcwait
    – Abraham
    Jul 25, 2013 at 11:05

2 Answers 2

2

I've answered this sort of question before (hint: search my previous answers; I'm on a mobile currently), but the problem you are likely facing is that an init script will not be shutdown if a the lock file has not been created (/var/lock/subsys/mything).

You can create this yourself for testing purposes, but the catch is you'll need to have this script run at startup too; just to at least create the lock.

Study something like the init script for crond

Cheers, Cameron

0

It looks like there is a configurable timeout value before the script is killed. See this answer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .