peppeocchi / php-cron-scheduler

PHP cron job scheduler
MIT License
808 stars 143 forks source link

How does the lock file removed #121

Closed mitmelon closed 3 years ago

mitmelon commented 3 years ago

I use this code to run a script every minute with the onlyOne() method to avoid overlapping $scheduler->php($script)->onlyOne()->everyMinute();

My question that once this scripts complete execution how will the lock files be removed... Or am i to remove them myself once execution is over?

peppeocchi commented 3 years ago

@mitmelon the lock file is only removed by the scheduler when executing a Callable job, because it's the only time the scheduler knows when the job is completed. In all the other cases, without knowing when the job is complete, the lock file will stay there and you will have to remove it manually. That being said, if you don't manually specify the temp folder for the lock file, it will be stored on the temp folder of your system (https://github.com/peppeocchi/php-cron-scheduler/blob/master/src/GO/Job.php#L171), which will be cleaned up automatically by your OS.

If you have any suggestion on how to remove lock files (specially for async jobs) please feel free to open a PR

mitmelon commented 3 years ago

@peppeocchi Thanks very much I will look for means to see if that could happen and open a pr.