Git Product home page Git Product logo

Comments (8)

tcarpenter2014 avatar tcarpenter2014 commented on July 24, 2024 1

Hi Marc,
I am seeing this on a Linux server. Under some unknown condition, could be an exception or something else, the cron.lock file does not get deleted after a cron run and every minute after that I get a failed cron run and the following logged to the Laravel log for each cron run after that:

dev.WARNING: Lock file found - Cron is still running and prevent job overlapping is enabled - second Cron run will be terminated.

After the first time it occurs you can see that the cron.lock file time stamp does not change which means it does not get deleted so each cron run after that will not run because it thinks the previous cron is still running, which it is not. When I manually delete the -1 entries from cron_manager table and manually delete the cron.lock file cron run will start running normal. I am just trying to figure out would could cause this and how I can catch it and fix it without having to manually delete table rows and the cron.lock file.
Thanks,
Troy

from cron.

tcarpenter2014 avatar tcarpenter2014 commented on July 24, 2024

I cleared out my cron_manager table and deleted the cron.lock file and everything started working fine again. The cron is run every minute as set by the default. But then for no reason the cron starts returning -1 and logging says lock file was found. Once the cron.lock file is created, when does it get deleted? Until it is removed the cron jobs will not process correctly.

from cron.

tcarpenter2014 avatar tcarpenter2014 commented on July 24, 2024

It looks like once the cron.lock file gets created the only way I can correct things and get the cron jobs running correctly again is to remove the row entries in the cron_manager table and then delete the cron.lock file. I am assuming there has got to be an automated way to correct this issue as opposed to doing manual deletions?
Thanks,
Troy

from cron.

liebig avatar liebig commented on July 24, 2024

Hi Troy,
The cron.lock will be created when Cron starts and will be deleted when the Cron job execution is done. I use for this the unlink function. On some systems (especially Windows) this can fail. From the READEME: On some Windows machines the lock file cannot be deleted. If you see a delete error message in your log, please disable this feature. So please disable this feature with Cron::setDisablePreventOverlapping();.

Best Regards,
Marc

from cron.

liebig avatar liebig commented on July 24, 2024

Hi Troy,
you can disable this prevent overlapping feature with the function call Cron::setDisablePreventOverlapping();. Add this to your Event::listen('cron.collectJobs', function() { ... } block. After that Cron will not create the cron.lock file and will not check if this file exists.

Additionally you can check the access rights to the cron.lock file. Maybe the PHP process don't have the rights to delete this file. Maybe the PHP user is not the owner of this file. You can create a simple test PHP file with the unlink function enclosed to test if you can delete the cron.lock file with PHP.

I ran my last Composer update with the root user, so the owner of all the PHP files where root. This can cause problems. In this case, please change the owner of all you PHP files to your PHP user.

I hope this helps you.

Best Regards,
Marc

from cron.

tcarpenter2014 avatar tcarpenter2014 commented on July 24, 2024

Thanks for the reply. Turning off overlapping is not really something I want to do because I do not want cron to try to run a command while another is still running. So I'm thinking I will just create a watch on the cron.lock file and if the timestamp shows that it is older than the default interval then it will get deleted. That would be a nice feature to have in the liebig package. Some sort of setting or static code that checks the cron.lock file against the previous run date and time and if it is older then go ahead and delete it.

from cron.

liebig avatar liebig commented on July 24, 2024

Hi Troy,
The problem with the delete old cron.lock file is, that if this file could not be deleted after the Cron run, it could probably not be deleted at the next Cron run. I use the default PHP unlink function and if it fails once it will fail again and again. You can listen to the event cron.locked, which is fired if lock file was found. If you find a PHP function which deletes files more reliable than unlink please let me know.

from cron.

liebig avatar liebig commented on July 24, 2024

Closed due to inactivity.

from cron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.