Setting a cron job to run exactly every 24 Hours

  • Posts: 268
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 7 months ago #350793

-- url of the page with the problem -- : maineroots.org
-- HikaShop version -- : 4.7.2
-- Joomla version -- : 3.10.11
-- PHP version -- : 7.4.33
-- Browser(s) name and version -- : Chrome

How can I get the hikashop cron to run exactly every 24 hours?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 7 months ago #350795

Hi,

What do you want to run every 24 hours ?
Usually, you want the cron task to run with a higher frequency, like every 15 minutes. Then, in each plugin / feature using the cron task, there is usually a frequency setting you can use to set the frequency you want for it.
So for example, if you want to use the HikaShop rates auto update plugin to refresh the exchange rates once every day, you can configure its frequency to 86400. Then, as long as the frequency of the HikaShop cron is smaller than 1 day, the plugin will run once every day.
In fact, to get a more precise frequency of 1 day, it's better to make the main cron task frequency as high as possible, like every minute.

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

  • Posts: 268
  • Thank you received: 7
  • Hikamarket Frontedition Hikamarket Multivendor Hikaserial Standard Hikashop Business
1 year 7 months ago #350808

It is a mass action to email orders placed within the past 24 hours to a fulfillment center.
I've got the mass action set to:
Triggers - Every days
Filters - Order_created > {time}-86400

Then in the hikashop cron configuration
Minimum delay between two cron tasks set to 15 minutes

The problem is is that it is running at different times during the day. Need to run exactly at the same time once a day.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 7 months ago #350809

Hi,

That's not possible.
First, you should change the delay between two cron tasks to 1 minute, and not use the cron we provide, but something like cron-job.org/en/ so that you can have the cron triggered every 1 minute.
That way, you'll reduce the time difference between 2 days to only 1 minute, instead of 15 minutes with how it is setup right now.

Then, I would recommend changing the logic of your cron:
- instead of {time}-86400 I would recommend something like {time}-100000 to make sure you're not leaving some orders out
- create a custom order field "sent_to_fulfillment"
- add a filter in your cron with sent_to_fulfillment < 1 so that orders with 1 in the sent_to_fulfillment field will be ignored
- add an action "update the values" on sent_to_fulfillment with the value 1 so that once an order is sent to fulfillment, 1 will be in the sent_to_fulfillment column so that the order can be ignored

Doing it this way will also ensure that if your server is down, or the cron stops for some reason ( for example the internet connection of your hosting is down for a few hours ), you'll know where it stopped, the system will be able to resume automatically, and you'll get a flag to know if you missed some hours while the website was down.

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

Time to create page: 0.060 seconds
Powered by Kunena Forum