SOLVED Is there a timeout for cron jobs?

Joined
Mar 5, 2022
Messages
224
I have been looking for a solution to this but have not found one yet:

I have a backup script that runs rsync and then compares the folders to ensure the data was backed up successfully. It logs as it goes along and zips the log file when done. This can easily take a few hours to run.
If I run it manually, it completes, but if I leave it to the crontab (set from the web interface), it just as often does not.

Does freebsd impose time limits for cron jobs? Can I over-ride it?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
No, it doesn't. No time limits.

You can add something like this to the top of your script to catch all of the output:
exec >/tmp/myscript.log 2>&1
 
Joined
Mar 5, 2022
Messages
224
Thanks for the response. I guess I failed to mention that it was a python script... I just added a try/catch around the top-level call... Maybe that reveal something. Thanks for the suggestion!
 

Arwen

MVP
Joined
May 17, 2014
Messages
3,611
Cronjob failures can occur due to PATH issues. Make sure your executables and scripts are either in the limited PATH of cronjobs, or that you fully list the directory structure needed to find the file. Alternatively you can reset the PATH or other ENVs as needed.
 
Joined
Jun 2, 2019
Messages
591
@jordanthompson

Make sure the script has execute permissions and appropriate shebang (#!) on the first line

Code:
chmod a+x {filename}
 
Joined
Mar 5, 2022
Messages
224
The problem is not with the script not running as a cron job, the problem is that it hangs after a few hours... I am still chasing this issue but @PatrickMHausen gave me the idea to wrap the top-level call in a try/catch (maybe I'll catch something ;-)
 
Top