Magento Cron Retry on Script Termination
I'm having an issue with a Magento cron. I have a method in a Helper Class firing via the cron, but at some p开发者_如何转开发oints the the method logic, I exit with an error code (ie error(1)
) if there are issues with files that the method is working with. It seems that if the method doesn't end normally, Magento cron tries to re-run the script until it hits the 'Missed if Not run In' limit set in the config.
I tried exiting with a success code (ie exit(0)
), but that doesn't seem to help. Is there a graceful way to do this so that Magento doesn't try to re-run the script if it errors-out?
user923990 gave this answer in his own question:
Wrapping the code in a try-catch and allowing it to exit normally closes out the cron job. Exiting with a die()
or any sort of exit()
(even exit(0)
) causes Magento to think the job has failed and it will try to run it again.
精彩评论