Advertisement
MattePRL

Mongod process restarter for cron

Apr 22nd, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import os
  4. import commands
  5. import datetime
  6.  
  7. now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
  8.  
  9. try:
  10.         int(commands.getoutput('pidof mongod'))
  11.         print ("[{0}] Mongo is fine, nothing to see here...").format(now)
  12. except:
  13.         os.system("/bin/bash /etc/init.d/mongod start")
  14.         print("[{0}] Mongo died. Restarting...").format(now)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement