How do I increase timeout for a cronjob/crontab?

人盡茶涼 提交于 2021-02-16 06:03:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!