Magento 1.7 - Cron.php: too late for the schedule - magento

I created some modules to be executed by magento cron but i get always the error.
The numbers:
Cron.php gets executed every 5 minutes
system/cron/schedule_generate_every = 15
system/cron/schedule_ahead_for = 30
system/cron/schedule_lifetime = 15
The module cronjobs should be executed every 5 minutes.
They are added correct to cron_schedule to be executed i.e. at 2014-01-16 16:40:00, 2014-01-16 16:45:00, 2014-01-16 16:50:00 ...
But on execution in 16:50 i get lots of errors. exception 'Mage_Core_Exception' with message 'Too late for the schedule.' also for jobs in the future.
Perhaps: our local time is 17:50, server time 16:50. But i can't remember we had this issue before on other cronjobs.

If the cronjob runs every 5 minutes, try this configuration:
Generate Schedules Every 5
(enter here the cronjob execution time, in this case 5 minutes)
Schedule Ahead for 125
(based on cronjob execution time plus the maximum time one job needs. For example: sitemap generation takes 120 minutes, then enter 120 minutes + 5 = 125 minutes)
Missed if Not Run Within 180
(runtime of the longest process, for example: an import takes 120 minutes, then enter 120 minutes + 60 minutes - because sometimes there is a difference between mysql and server time)
History Cleanup Every 10
(minimum cronjob execution time = 5 * 2 = 10 minutes in this case)
Success History Lifetime 1440
(duration of cronjob storage, to proof if everything works fine. 1440 = 24 hours)
Failure History Lifetime 1440
(duration of cronjob storage, to proof if there is an error. 1440 = 24 hours)
And last but not least, install AOE-Scheduler for a visual inspection of your cronjobs.
http://www.magentocommerce.com/magento-connect/aoe-scheduler.html

Related

Can I apply factor when running load tests jmeter

I have the following scenario:
every 1/2 hour a user send a file to the server
every 5 seconds a user pings the server
do it for 4000 users during 24 hours
my question is, can i do the following and achieve the same results?
every 15 minutes a user send a file to the server
every 2.5 seconds a user pings the server
do it for 2000 users during 24 hours
thanks.
Add Thread Group to your Test Plan and configure it to have 4000 virtual users, loop forever and run for 84600 seconds (24 hours * 60 minutes per hour * 60 seconds per minute)
Add a HTTP Request to ping the server
Add Constant Throughput Timer as a child of the HTTP Request sampler and configure it to fire 12 times per minute (60 seconds in minute / 5 seconds)
Amend Calculalte throughput based on dropdown value according to your test scenario (whether each user or any user should ping the server each 5 seconds)
Apply the similar configuration for remaining use cases.

Cron schedule a task alleatory in a range of hours

I want schedule with cron a task to be ran ONCE in between a certain tange of hours, not every hour in a range.
Example:
I want it may run ONCE between 9 to 12 hours, single time.
Better if I can run the task ONCE between 9 to 12 hours and random minute as well. I don't want can be predictable, but I want keep control about in which range of hours it will be fired.
I tried:
# m h dom mon dow command
00-59 09-12 * * 2 /home/osmc/play.sh
But it ran every minute, between 00 and 59, for every hour between 9 to 12 (not desired)
Any idea how I can do so?
If you like to stick with cron, you could do the following:
0 9 * * 2 sleep $(( RANDOM \% 10800)); /home/osmc/play.sh
The job will start at 9AM, and delays the script for upto 10800 seconds, which is 3 hours.
Another solution found here:
Cron jobs and random times, within given hours

Call cron.php once a day - Magento settings

Like a lot of users i've some problems configuring Magento cronjobs (my cartrules doesn't update properly on Magento 1.8.1. I also modified my cron.php adding $isShellDisabled = true;).
A tried a lot of things, but it doesn't work. Installed AOE scheduler, and i see all my tasks as pending!
My hosting let me to call cron.php once a day (3 am, and it's working, becase it generates the tasks at that time), so i'm wondering if is useless having settings like this:
Generate Schedules Every 15
Schedule Ahead for 1
Missed if Not Run Within 60
History Cleanup Every 120
Success History Lifetime 1400
Failure History Lifetime 1400
If i run manually the cron.php, it generates tasks for a hour, all pending (for example, my cart rules XML are set to update every 15 minutes, so i get 4 cartrules tasks)
If i run it again (after few minutes), all tasks between this time change form Pending to Success.
So, have i to call it at least twice a day? Or i have to change my cron settings?
thank you for the help
Use this cron expression for each hour:
<cron_expr>0 * * * *</cron_expr>
This will make it run at 12.00, 1.00 and so on.
If you want to make it run at 12.30, 1.30 and so on replace 0 with 30

CRON: Run job on particular hours

I have a spring batch application and i am using CRON to set how often this application runs. But the problem i am running into is that i want to run the job on specific hours
3 am
7 am
11 am
3 pm
7 pm
11 pm
As you can see it is every 4 hours but starts at 3 am so i cannot use */4 in the hours section of the timing format as this would start the job at 4am
I have also tried '3,7,11,15,19,23' in the hours section but this does not work either (guessing it only works in the minutes section). Does someone know how i can do this?
Use
#Scedule(cron="0 0 3/4 * * ?")
The Pattern x/y means: where <timepart> mod y = x
or
#Scedule(cron="0 0 3,7,11,15,19,21 * * ?")
According to the Quartz Cron Trigger Tutorial:
The '/' character can be used to specify increments to values. For
example, if you put '0/15' in the Minutes field, it means 'every 15th
minute of the hour, starting at minute zero'. If you used '3/20' in
the Minutes field, it would mean 'every 20th minute of the hour,
starting at minute three' - or in other words it is the same as
specifying '3,23,43' in the Minutes field. Note the subtlety that
"/35" does *not mean "every 35 minutes" - it mean "every 35th minute
of the hour, starting at minute zero" - or in other words the same as
specifying '0,35'.
0 0 3,7,11,15,19,23 * * ?
Fires for 0 minute starting at 3am and ending at 23:00 pm every day.
judging by the two answers above the error i was making was i was keeping the apostrophe at the start and end of my hours... very silly
i managed to solve this by using 3-23/4 for the hour as this starts from 3am and then every other fourth hour (just a different way of doing it to the other answers)

quartz spring cron trigger fire immediately

I have a spring application that uses quartz cron trigger. I have given the following for frequency 0 0/20 * * * ?.....once every 20 min. But i want the first one to run immediately. Right now, when I start the application, it runs after 20 min. I was hoping it would run asap and then after 20 min.
Thanks in advance.
It sounds like you want to use an interval trigger (SimpleTrigger in Quartz can do the job).
The CronTrigger wants you to specify the minutes at which to run.
So your trigger schedule says: start at 0 minutes, and run every 20 minutes after that until the hour is over. Then start at 0 again.
But with the SimpleTrigger, you say - start now and run every 20 minutes.
Here is a tutorial on SimpleTrigger:
http://quartz-scheduler.org/documentation/quartz-2.x/tutorials/tutorial-lesson-05
Here is a tutorial on CronTrigger:
http://quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger
You don't need CRON expression (and Quartz at all!) to run given code every 20 minutes. Just use fixed rate (Spring built-in):
#Scheduled(fixedRate=20 * 60 * 1000)
That's it! By default first invocation happens immediately, second after 20 minutes. Since Spring 3.2 you can even say initialDelay=10000 to run for the first time after exactly 10 seconds.
If you really want to use Quartz, check out SimpleTrigger.

Resources