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

problem with repaet job #17

Closed
amirkheirabadi73 opened this issue Mar 29, 2014 · 5 comments
Closed

problem with repaet job #17

amirkheirabadi73 opened this issue Mar 29, 2014 · 5 comments
Assignees
Labels

Comments

@amirkheirabadi73
Copy link

hi ...
I after add new cron , played it ...
But only once the function is executed ...
i use full example in readme ...
What should I do to make this cron will continue ?

@liebig
Copy link
Owner

liebig commented Mar 30, 2014

Hi Amirkheirabadi, thanks for using cron. Which function is only exectued once? Do you call the Cron route manually? Which operation system is running with Cron? Maybe there is a problem with the overlapping feature. On some Windows systems the lock file could not be deleted. Please have a look in your app/storage/ directory if there is a cron.lock file and please delete it. Use the 'Cron::setDisablePreventOverlapping();' method call to disable the overlapping function. I hope this helps.

@liebig liebig self-assigned this Mar 30, 2014
@amirkheirabadi73
Copy link
Author

hi liebig ... thanks for reply ...
i am use mint ...
for example :

Route::get('/cron/run/c68pd2s4e363221a3064e8807da20s1sf', function () {
    Cron::add('example1', '* * * * *', function() {
                        // Do some thing
                        return null;
                    });
    $report = Cron::run();
    print_r ($report);
});

when i past this code ... function :

function() {
                        // Do some thing
                        return null;
                    }

only once execute . but i need to execute this function every 1 min for example ..
thanks

@liebig
Copy link
Owner

liebig commented Mar 30, 2014

Hi amirkheirabadi, okay I understand the problem. A PHP application only runs when you call it (for example via request). Laravel and Cron will be loaded then, executed and after returning the response the application will be termined. It is not possible to run a PHP application over hourse like a Tomcat Server do. So you need something which call the route "/cron/run/c68pd2s4e363221a3064e8807da20s1s" every minute. Cron only checks, if it is executed, which jobs have to be run and which jobs not. So if you only have one job for every minute, you don't need Cron. You can easily do all the business logic in this route without Cron. But if you have a job for every minute, two jobs for every 15 minutes and so on, Cron can help you.

"Now we have to ensure that this route is called in an interval. This can be done with renting an own (virtual) server or with an online cronjob service. In both cases Google knows many good providers. An online cronjob service overview can be found at http://www.cronjobservices.com/"

Now your server or an online cronjob service will call the Cron route for example every minute, Cron will check which jobs need to be exectued (for example the every minute jobs '* * * * *') and will log the return values. But you always need something which call Cron, because if Cron is not running it is sleeping.

@amirkheirabadi73
Copy link
Author

oh ... thanks ... this is good idea ...
for last question . i now use crontab in app for schedule . you know way to i able to manage this with code in laravel ?

@liebig
Copy link
Owner

liebig commented Mar 30, 2014

Unfortunately it is not easily possible to manage crontab with PHP. You need SSH access to the server. You can find a guide here: http://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

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

2 participants