We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed last year.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您可能需要将锁定逻辑添加到PHP脚本中。例如,脚本可能会检查锁定文件是否存在,如果存在则中止。否则,它将创建该文件并在完成后将其删除。您可以在脚本中添加其他逻辑,例如检查上次运行时间,如果上次运行时间不到 1 小时则中止。
对于 cron 作业,您可以基于脚本负责检查锁、上次运行时间等的假设来设置激进的计时(例如每 5 分钟一次)。
You might want to add the locking logic into your PHP script. E.g. the script might check for the presence of a lock file and abort if it is present. Otherwise it would create that file and delete it after it is done. You can add additional logic into your script for example checking the last time it was run and abort if it was last run less than 1 hour ago.
As for cron job, you can set up aggressive timings (say every 5 minutes) based on the assumption that the script is responsible for checking locks, last run time etc.
您应该尝试使用作业队列。
有一些是用纯 PHP 实现的(例如 Zend 作业队列)或安装一个守护服务,如 beanstalkd (使用 PHP-API,如 Pheanstalk。)
You should try a job queue.
There are some implemented in pure PHP (Like the Zend Job Queue) or install a deamon service like beanstalkd (With a PHP-API like Pheanstalk.)