1

I have a requirement which needs to be done via cron. Some of the jobs should run only in time frame of 9AM-7PM everyday. So how I can schedule a cron for this type of requirements in the crontab.I surfed around it, but didn't get any solutions so please anybody help me in this regard.

0

To run cron you have to have something that triggers the cron since php is a scripting language and only fires off when executed. What that means is you either need an outside resources to fire off the cron or you need to set it up server side. You can set up a cron service on linux by following the guide on Drupal.org. If a scheduled cron task is not set up on the server side or some other mechanism then cron will simply run the next time a user goes to your site. This could have performance issues and unreliable cron runs.

Custom Module

If you don't want your cron task to run every single time cron runs then in your code you would set it up to check the current time and whether or not to run. This would require use of the date functions in php and allow you to decide whether or not to execute your code based off the time

Elysia Cron

Elysia cron will allow you specifically set which cron tasks run at certain times. This will require you to still set up a cron task so that cron can still fire.

  • Thanks fro your suggestions. I installed Elysia Cron but I am not getting settings to reach my requirement, which is between 9AM to 7PM only it should run the cron. am I missing something in configuration or that functionality is not there? – Suraj Aug 1 '18 at 6:07
  • I think I may have misunderstood the original requirement. Do you want it to run every single time cron runs between that time, or how many times do you want it to run? – chadpeppers Aug 1 '18 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.