Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The man page seems to indicate no. There is /etc/rc.d/init.d/halt on Fedora. It has a hard coded pause in it, but there's got to be a better way than to change that script. Any help would be appreciated.

share|improve this question

migrated from stackoverflow.com Jan 1 '11 at 20:52

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

The manpage on my system has:

-t sec Tell  init(8)  to  wait sec seconds between sending
processes the warning and  the kill signal, before changing 
to another runlevel.

(This is probably a more appropriate question for serverfault)

share|improve this answer
1  
Is this what wants the OP? A delay between the warning and the actual shutdown? Or a delay between SIGTERM (ask gracefully the processes to terminate) and SIGKILL (kill processes immediately)? –  ring0 Jan 1 '11 at 8:06
1  
Have you tried it? That seems to be deprecated. I certainly can't get it to work on any distribution I've tried. –  s2cuts Jan 1 '11 at 8:06
1  
@ring0: the SIGTERM is the warning. –  wnoise Jan 1 '11 at 8:44
    
@s2cuts: I have. I'm running a reasonably current debian with the sysvinit package (2.88dfs). The "upstart" init replacement does indeed ignore this option. –  wnoise Jan 1 '11 at 8:49
1  
@ring0: I admit the man page is phrased badly. There is a text warning that is sent immediately, but it's sent to logged in users, not processes. Then it waits until the shutdown time to send both SIGTERM and SIGKILL, waiting the time given by the -t argument. In context, the warning referred to really does mean the warning signal of SIGTERM -- the only warning processes can receive is signals. –  wnoise Jan 1 '11 at 9:10
show 1 more comment

In order to have a specific delay between SIGTERM and SIGKILL, you could specify three commands in a script as root

kill -SIGTERM -1
sleep 20
kill -SIGKILL -1

to

  • send SIGTERM to all processes (but 1),
  • wait for 20 seconds, then
  • send the -9 signal to kill immediately the remaining processes,

but it would kill your own processes, your shell interpreter...
Developing a script (e.g. in Perl) to list all processes, then to kill only the processes that do not harm your own script, and start it within nohup to attach it to the father-of-all 1 process, would do the job.

Another solution is to download the source of shutdown (or halt) and see how it works - adding a fixed or optional delay between the sending of the two signals shouldn't be too hard.

share|improve this answer
    
This is probably the closest to a solution. I've already modified /etc/rc.d/init.d/halt and put a more suitable pause in between the sending of SIGTERM and SIGKILL. The only problem is that it's hard coded. –  s2cuts Jan 9 '11 at 19:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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