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

Exception Impossible CRON expression raised on php-5.5.15(debian) #31

Closed
lokielse opened this issue Aug 9, 2014 · 15 comments
Closed

Exception Impossible CRON expression raised on php-5.5.15(debian) #31

lokielse opened this issue Aug 9, 2014 · 15 comments
Assignees
Labels

Comments

@lokielse
Copy link

lokielse commented Aug 9, 2014

Hi @liebig , Here raise an exception after I upgrade my php from 5.4.9 to 5.5.15 today.

I did not change anything of my code, and I found that there raise an exception said Impossible CRON expression in CronExpression.php line at line 321 and cron.lock created in storage path.

for example, all the follow will not work(Impossible CRON expression)

0 1 * * *
0 2 * * *
0 4 * * *
0 5 * * *

but the follow will work!

0 0 * * *
0 3 * * *
0 6 * * *
0 9 * * *
0 12 * * *

so strage issue. need your help!!!

@liebig
Copy link
Owner

liebig commented Aug 11, 2014

Hi @lokielse, thank you for your message. That really sounds strange. I will check this.

@liebig liebig self-assigned this Aug 11, 2014
@liebig liebig added the bug label Aug 11, 2014
@liebig
Copy link
Owner

liebig commented Aug 11, 2014

Okay I installed PHP Version 5.5.15-1~dotdeb.1 and have the following code:

Route::get('cron/test', function () {

    Cron::setDisablePreventOverlapping();
    Cron::setDatabaseLogging(true);
    Cron::setLogOnlyErrorJobsToDatabase(false);

    Cron::add('test_cron_1', '* * * * * *', function () {
    });

    Cron::add('test_cron_2', '0 0 * * *', function () {
    });

    Cron::add('test_cron_3', '0 1 * * *', function () {
    });

    Cron::add('test_cron_4', '0 2 * * *', function () {
    });

    Cron::add('test_cron_5', '0 3 * * *', function () {
    });

    Cron::add('test_cron_6', '0 4 * * *', function () {
    });

    Cron::add('test_cron_7', '0 5 * * *', function () {
    });

    Cron::add('test_cron_8', '0 6 * * *', function () {
    });

    Cron::add('test_cron_9', '0 9 * * *', function () {
    });

    Cron::add('test_cron_10', '0 12 * * *', function () {
    });

    return Cron::run();
});

Unfortunately it works for me and I don't get the Impossible CRON expression. Can you provide me your code?

@lokielse
Copy link
Author

I use your code snippet one by one.
cron commit hash 40aeff3f52038474abee47a3716c64a803dfd683

this work

Cron::add('test_cron_1', '* * * * * *', function () {
});

this one not work

Cron::add('test_cron_2', '0 0 * * *', function () {
 });

and I truncate tables cron_job and cron_manageer.

Then after I reinstall your cron lib just now.

this one work

Cron::add('test_cron_2', '0 0 * * *', function () {
 });

but this one not work

Cron::add('test_cron_3, '0 1 * * *', function () {
 });

I guess that it related to the time.

@lokielse
Copy link
Author

@liebig
Copy link
Owner

liebig commented Aug 11, 2014

That is really strange. I only get the Impossible CRON expression if the expression is only for the past. For example Cron::add('test_cron_1', '* * * * * 2014', function () {});works fine but Cron::add('test_cron_1', '* * * * * 2013', function () {}); does throw the exception. This behaviour is correct because using an expression which will never be true is an error. Please try to use Cron::add('test_cron_2', '0 0 * * * *', function () {});. Can you print the complete stack trace?

@lokielse
Copy link
Author

19. RuntimeException
…/­vendor/­mtdowling/­cron-expression/­src/­Cron/­CronExpression.php321
18. Cron\CronExpression getRunDate
…/­vendor/­mtdowling/­cron-expression/­src/­Cron/­CronExpression.php157
17. Cron\CronExpression getNextRunDate
…/­vendor/­mtdowling/­cron-expression/­src/­Cron/­CronExpression.php252
16. Cron\CronExpression isDue
…/­vendor/­liebig/­cron/­src/­Liebig/­Cron/­Cron.php219
15. Liebig\Cron\Cron run
…/­workbench/­pay/­union/­vendor/­illuminate/­support/­Illuminate/­Support/­Facades/­Facade.php205
14. Illuminate\Support\Facades\Facade __callStatic
…/­app/­routes.php32
13. Liebig\Cron\Facades\Cron run
…/­app/­routes.php32

@lokielse
Copy link
Author

laravel config app.php

  'timezone'   => 'PRC',

php.ini

date.timezone = PRC

@liebig
Copy link
Owner

liebig commented Aug 11, 2014

Seems to be a timezone problem. Please try to change laravels timezone to UTC.

@lokielse
Copy link
Author

Yeah! solved.

I should use timezone PRC, but php5.5.15 may not support PRC

I use Asia/Shanghai instead and it works!!!

hahaha ;D

@lokielse
Copy link
Author

thanks @liebig

@liebig liebig added question and removed bug labels Aug 11, 2014
@liebig
Copy link
Owner

liebig commented Aug 11, 2014

I am glad to hear this :) You are always welcome, @lokielse!

@lokielse
Copy link
Author

http://php.net/manual/en/timezones.others.php

here is a warning.

Warning

Please do not use any of the timezones listed here (besides UTC), they only exist for backward compatible reasons.

@iClosedz
Copy link

Hello,
I have question

So it need to add time zone in
laravel config app.php

'timezone'   => 'Asia/Shanghai',

and php.ini

date.timezone = Asia/Shanghai

or only in the laravel config app.php ?

Thank you.

@lokielse
Copy link
Author

Both better while I changed only laravel config

@iClosedz
Copy link

OK Thank you.

I have a little bit confuse about this cron package but I will create a new issue.

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

No branches or pull requests

3 participants