问题
I have written a script that gets data from solr for which date is within the specified period, and I run the script using as a daily cron.
The problem is the cronjob does not complete the task. If I manually run the script (for the same time period), it works well. If I reduce the specified time period, the script runs from the cron as well. So my guess is cronjob is timing out while running the script is there is much data to process.
How do I increase the timeout for cronjob?
PS - 1. The script I am running in cronjob is a bash script which runs a python script.
回答1:
You could try to use ulimit -t [number of seconds] in the cronjob before running the script.
回答2:
Note that the ulimit -t
solution suggested will limit the amount of CPU time used, not the amount of actual time that has passed.
From the bash
manpage:
ulimit [-HSTabcdefilmnpqrstuvx [limit]]
...
-t The maximum amount of cpu time in seconds
And more importantly, cron doesn't impose any timeouts in the first place. It simply kicks off whatever process and moves on.
BTW: Sorry for posting this as an answer, but I don't have enough points to add comments yet.
来源:https://stackoverflow.com/questions/599588/how-do-i-increase-timeout-for-a-cronjob-crontab