Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried putting script like this:

date >> /home/date

It works when the network cable removed manually and i have inserted the script in /etc/network/if-down.d. It is not working when the swtich is off. Can any one please tell me how to write script for this?

share|improve this question
out of curiosity, why should a server halt when the network drops? – warren Nov 9 '09 at 9:56
our client are facing a lot of power fluctuations, if the ups drained out in middle of night, the servers will shutdown abruptly so better to write a script that's the reason. – Caterpillar Nov 9 '09 at 11:07
That's your solution? You know, UPSes can tell the server that they're running out of power and it's time to shut down gracefully... – womble Nov 9 '09 at 11:14
i know that, But that stupid ups provider has not given any cable to it... :-( otherwise i could've done like that..Please tell me how to write script. – Caterpillar Nov 9 '09 at 12:35
I think for business purposes it might benefit you to do it right and spend whatever money is required to get the cable. What type of UPS is it? – oneodd1 Nov 9 '09 at 19:30

This is obviously a rather ugly hack. But you could put a script into crontab that periodically checks for network & shuts down the system if it's no longer there. Sort of a Dead man's Switch.

share|improve this answer
you're right, that is an ugly hack. +1, i like it. :) – quack quixote Nov 9 '09 at 13:21

Have you tried putting your script in /etc/network/if-post-down.d/?

share|improve this answer
Yeah! I tried it, But did'nt work.. :( – Caterpillar Nov 9 '09 at 11:08
I don't see how this could work. AFAIK, /etc/network/if-post-down.d/ is called if the network connection is shut down locally (by calling the approriate shutdown programs/scripts). It is not invoked if the network just dies for reasons outside the local system. – sleske Dec 7 '11 at 8:29

is the script chmodded as executable?

chmod +x /etc/network/if-down.d/*scriptname*
share|improve this answer
Yeah!! without that script will not run.. :) i have done.. – Caterpillar Nov 9 '09 at 12:36

Your Answer


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.