-
Notifications
You must be signed in to change notification settings - Fork 64
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-job running twice #72
Comments
Thank you for using Cron. I am sorry about this issue and I will try to fix it. There were some issues with the problem "Cron job is running twice" like #67, but you are the first user who sends me the log file. Thank you for that. To localize the bug, can you please test if this problem does occur if you run Cron via web request and the integrated route, too? To do this please set the |
I have set the crontab to run the job every 2 minutes using your script :
But it is not running. I think there is some problem. Again I'm pasting the laravel logs for today:
If I hit the url in my browser to run the cron like:
It does not gives me any error but not firing the job I think because I'm not receiving the emails. |
Thank you for your reply. Please change the url value <?php
return array(
// Interval defines the time in minutes between two run method calls - in other words, the time between the Cron route or command will be called
'runInterval' => 1,
// Should the Laravel integrated logger handle the logging
'laravelLogging' => true,
// Enable or disable database logging
'databaseLogging' => true,
// Enable or disable logging error jobs only
'logOnlyErrorJobsToDatabase' => false,
// Delte old database entries after how many hours - if this value is set to 0, no entries will be deleted
'deleteDatabaseEntriesAfter' => 240,
// Prevent job overlapping - if Cron is still running it could not be started a second time
'preventOverlapping' => true,
// Enable or disable the check if the current Cron run is in time
'inTimeCheck' => true,
// Cron application key for securing the integrated Cron run route - if the value is empty, the route is disabled
'cronKey' => 'secretKey12345'
); global.php Event::listen('cron.collectJobs', function() {
Cron::setEnablePreventOverlapping();
Cron::add('user_analytics_report', '* * * * 2', function() {
$maildata = array('email' => 'someemail@somedomain.com');
Mail::send('emails.analytics', $maildata, function($message){
$message->to('user@gmail.com', 'firstname lastname')->subject('Some subject');
});
return null;
});
}); Crontab
Or use your browser and call Many thanks in advance. |
Sorry for the late reply, but I had many things to do in the last days. I think I have got a solution for this. This behaviour is not a bug. Please just delete this from the global.php file: $report = \Cron::run();
return null; Now Cron should only run once. If you use the artisan command or the integrated route you don't have to execute Event::listen('cron.collectJobs', function() {
Cron::setEnablePreventOverlapping();
Cron::add('user_analytics_report', '* * * * 2', function() {
$maildata = array('email' => 'someemail@somedomain.com');
Mail::send('emails.analytics', $maildata, function($message){
$message->to('user@gmail.com', 'firstname lastname')->subject('Some subject');
});
return null;
});
}); Please test this and give me a short reply. |
Closed due to inactivity. |
I am using laravel 4.2.
I've a project requirement to send some analysis report email to all the users every Monday 6 am.
Obviously its a scheduled task, hence I've decided to use cron-job.
For this I've installed liebig/cron package. The package is installed successfully.
To test email, I've added following code in app/start/global.php:
Also in app\config\packages\liebig\cron\config.php the key
preventOverlapping
is set totrue
.Now, if I run it like
php artisan cron:run
, it sends the same email twice with the same time.I've deployed the same code on my DigitalOcean development server (ubuntu) and set its crontab to execute this command
every minute
but still it is sending the same email twice.The crontab command is:
Also it is not generating lock file in ``app/storage` directory, according to some search results I've come to know that it creates a lock file to prevent overlapping. the directory has full permissions granted.
The laravel logs are as :
The database table entries are as :
cron_job :
cron_manager:
Am I missing something?
The text was updated successfully, but these errors were encountered: