0

I have a cron job in my application which does the following:

  1. It gets entries from a database table whose status is set to 'pending'. Columns list is as below: id,name,title,ip,status
  2. For each such entry it does a REST (Web service) call, get response, process it and store the data in database.

I presently set the cron job interval to 1 min. But sometimes, it's execution might take as much as 5-10 mins (rare cases).

For my case, is it important to handle concurrency of cron job? Using lock files etc?

Presently when a entry is being processed, i'm change the value of the entries state column to 'processing', so that it is not processed again by the next call of cron job.

4

1 回答 1

0

使用锁文件有额外的好处,如果相同的脚本被执行两次(错误地),只会执行第一个。

尽管您将列状态设置为“待定”,但我认为如果脚本执行两次(同时)仍然会有问题,除非您锁定了行/表。

于 2013-09-21T15:51:23.520 回答