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
:30and:31 - optionally correct placement of default exit code from line
:36 - optionally apply more logic if timeout is reached at line
:44 - optionally apply more logic if timeout is NOT reached at line
:48