cron job changing run time

  • Posts: 220
  • Thank you received: 8
2 years 1 month ago #346776

-- HikaShop version -- : 4.5.0
-- Joomla version -- : 3.10.6
-- PHP version -- : 7.4.33

Hi,

I'm using the Hikashop cron service.
* The cron of the Out of stock notification plugin is set to run at 02. 59 h
* 2 mass actions with the trigger "every day" are set to run one hour later, at 04.00 h (unix timestamp in namekey massaction_last_trigger_days)

This works fine in the first night : plugin at 03.08h and massaction at 04.07h
But after that the time is changing.
In the second and third night:: plugin at 04.07h and massaction at 05.08h.
However in the fourth night: plugin at 05.08h and massaction at 05.08h
In the fifth night: plugin at 06.08h and massaction at 06.08h
In the sixthh night: plugin at 076.08h and massaction at 07.08h

So the time difference between the two jobs disappears, and every subsequent night the jobs are running one hour later.
How to correct this undesirable behaviour?

Configuration cron task:
The minimum delay item between two crown tasks is 15 minutes
The frequency is every 1 hour. Sometimes it runs at xx.07h and sometimes at xx.08h

Kind regards,
Udo

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
2 years 1 month ago #346781

Hi,

The dates you set in the plugin and in the config for the mass actions is the "last time the process was run". And to be able to check if the process can run, it checks that the current date is bigger than the "last time the process was run" + the frequency.
So if a process runs at 1h00 one day and you have a cron task running once every hour at 00 minutes each hour, it means that the next day, when the the cron is triggered at 1h00, it won't be bigger than the "last time the process was run" + 1day, and thus is will want for the next cron task at 2h00.
To mitigate that, you could configure your cron task to run every minute. For example, this service can do it for you: cron-job.org/en/
That way, the process will only shift by 1 minute every day.

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 8
2 years 1 month ago #346805

Hi,
Thanks for your information.

If I understand correctly, it is impossible that crons jobs run every day at the same time.
If I set the Hikashop cron task at a frequency of 15 minutes then the run time will shift 15 minutes every day.

Isn't it overload to run a cron taks every minute?
Then the server is triggered 1440 times each day while only 2 moments a job has to be executed.
Does this slow the website down?

regards,
Udo

Please Log in or Create an account to join the conversation.

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
2 years 1 month ago #346817

Hi,

It's not overload. When you call the cron task URL, HikaShop will see if there is any processing to do. If there is none it won't do anything. So it's better to have a high frequency like "every minute" if you want as less time shift as possible, and it won't add any load on the website.

Please Log in or Create an account to join the conversation.

Time to create page: 0.058 seconds
Powered by Kunena Forum