0

Possible Duplicate:
Bash: Terminate on Timeout/File Overflow while Executing Command

I have a shell script to backup an O/S image. I want to set the time limit and notify me. If the shell script runs for longer than two hours, it needs to send the e-mail out. What is the best way to implement this logic?

Community
  • 1
  • 1
sfgroups
  • 18,151
  • 28
  • 132
  • 204
  • My suggestion would that another script starts your job (thus having its PID) and then sleeps for the time you want as threshold and then checks whether the other script is still running. This can be checked by PID or simply by the existence of a lock file or so. – 0xC0000022L Apr 11 '11 at 20:01
  • Multiple previous questions, including at least http://stackoverflow.com/questions/2626827, http://stackoverflow.com/questions/601543, and http://stackoverflow.com/questions/4355396. – Jonathan Leffler Apr 11 '11 at 20:04

1 Answers1

0

you can use ps command to check from how much time is the process running.

Aditya
  • 128
  • 1
  • 13