Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a script file which is run after a system crash when system starts. We need to run a special Database repair script if the server crashes (because of the power outage for example).

What would also help is some way of detecting a server crash at startup.

Thanks!

share|improve this question

migrated from stackoverflow.com Nov 20 '11 at 1:07

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

    
migrate to serverfault! migrate to serverfault! –  MK. Oct 20 '11 at 21:28
    
What do you mean? –  ddofborg Oct 21 '11 at 10:02
    
Sorry, my bad. Is there a way to move it? –  ddofborg Oct 21 '11 at 17:34
    
nah, don't worry about it. I said if have jokingly, I dont like the site fragmentation too much, but this one is actually sort of ok to migrate. –  MK. Oct 21 '11 at 20:00

1 Answer 1

up vote 2 down vote accepted

Gentoo has a directory /etc/local.d for scripts which will be run at system startup (if the filename ends with .start) and normal shutdown (if it ends with .stop). Off the top of my head I would suggest something like the following:

  • Create a .stop script which creates an empty file somewhere, to use as an indicator of a normal shutdown
  • Create a .start script which checks for the presence of the file and runs the DB repair script if it isn't found, or deletes it if it is found

I'm assuming that your database repair script won't cause any problems if it is run on an uncorrupted database.

share|improve this answer
    
This would be a good trick. Thanks. I was hoping for a /etc/crash.d or something. –  ddofborg Oct 21 '11 at 10:05

Your Answer

 
discard

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