Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cron not work on midnight #60

Closed
h-rafiee opened this issue Mar 12, 2015 · 5 comments
Closed

Cron not work on midnight #60

h-rafiee opened this issue Mar 12, 2015 · 5 comments
Assignees

Comments

@h-rafiee
Copy link

Hello,thanks for your library for Cron in laravel.
i test for every minute for cron
and add crontab for every minute it's work fine.
but i wanna cron for midnight and change * * * * to 0 0 * * for my Cron and crontab and boom not work...
checked cron manager on database and see rundate time is 05:10:25 like that any idea?!
screenshot from 2015-03-12 09 29 43
screenshot from 2015-03-12 09 32 00

@liebig
Copy link
Owner

liebig commented Mar 12, 2015

Hi @h-rafiee,
I am sorry for the problem with your job execution on midnight and I will try to help you. So you scheduled a Cron job for midnight(0 0 * * *) and added this expression to crontab, too. But the job does not run on midnight, but on 05:10:25?

Please check your Laravel timezone in your config/app.php file. This timezone should be the same to your system timezone. Please only use PHP supported timeszones. If this is correct, please change the Cron expression to every minute (* * * * *). Because crontab only runs Cron at midnight, the Cron job should only run once at midnight. While the expression is equals every minute, the Cron job will always run, if Cron is executed. You can also have a look at your Laravel log files. There you find information about Cron.

Another note, you don't have to enable the added Cron job with the function setEnableJob and the job name ordersValidation because it is enabled by default. And for testing it is a good way to return a String from the anonymous Cron function. But for production please return null if everything was okay or Cron will assume that there was an error while executing the job.

@liebig liebig self-assigned this Mar 12, 2015
@h-rafiee
Copy link
Author

Thanks it's works fine with crontab * * * * 👍

@liebig
Copy link
Owner

liebig commented Mar 16, 2015

Okay, then it seems to be a problem with your Laravel timezone. Please check.

@liebig liebig closed this as completed Mar 16, 2015
@liebig
Copy link
Owner

liebig commented Mar 16, 2015

Whups, did you mean with Cron or Crontab and the expression * * * * *? If the Cron expression is 0 0 * * * and crontab runs every minute, there will be a problem with crontab. But if you run crontab only once a day (0 0 * * *) and the Cron job always (* * * * *) and this works now, you have to check the Laravel timezone.

@h-rafiee
Copy link
Author

Now. i have two Cron jobs per minute and per day... i must run crontab for
every minute and Run all jobs . it's work fine thanks again

On Mon, Mar 16, 2015 at 2:45 PM, liebig notifications@github.com wrote:

Whups, did you mean with Cron or Crontab and the expression * * * * ? If
the Cron expression is 0 0 * * * and crontab runs every minute, there
will be a problem with crontab. But if you run crontab only once a day (0
0 * * *) and the Cron job always (
* * * *) and this works, you have to
check the Laravel timezone.


Reply to this email directly or view it on GitHub
#60 (comment).

Artist | Design & Interfaces
Iran
Software Engineer
Programmer

Designer

h.rafiee91@gmail.com
h.r1991@yahoo.com
h.rafiee91@chmail.ir

Twitter http://twitter.com/HRafiee91\- Deviantart
http://h-rafiee.deviantart.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants