I have a crontab job that executes a .sh script hourly. This script navigates(cd...) to a directory and then launches a java program (java -jar).
If I want to make sure the java program doesn't run for longer than 30 minutes, where should I set the timeout? Should it be in the crontab or in the .sh script?
Where you put the timeout is situation dependent. A metric I might use would be "What would most reduce the cognitive and maintenance burden on the next person (who might be me in a years time!)?" Sometimes, the context of the situation dictates to use an argument to the cronjob program, other times it is better to use timeout
. Other times, you might use ...
Context matters. What makes the most sense in your situation?