This little shell boilerplate can be used to run a long running program that has a custom exit state if a timeout is reached. Usefull to monitor by exit state.
The script basically sleeps for the allowed lifetime and touches a file if the parent process is still running. The running process IS NOT INTERUPTED, but after it finished a pre-defined exit state is retuned by the script if timeout was reached.
- Define exit code in line
:4
- optionally define lifetime in line
:7
- optionally define temp file in line
:10
- Insert long running code and delete lines
:30
and:31