I have a custom entity with a timestamp field which can be populated by the user.

At these specific "times" I have to "react" and update(execute some code) on some other entities related to this time.

First thing coming to mind is to implement it as a Cron job but, I'm not satisfied with this solution as I need to execute the code at a very specific time(any minute) while I don't want to set up the Cron(even a specific Cron job) to run every minute as it's sound quite overwhelming.

Are very any other ways to smartly manage a code execution based on specific(not hardcoded interval) time?

  • 4
    I don't think its overwhelming if you want to run the code every minute, just be sure your Cron execute only what you want, "manage a code execution based on specific time" is the definition of Cron.
    – Ziftman
    Apr 22, 2018 at 13:59
  • I think you can take a look at Rules module. It helps trigger actions at certain events at specific times but again, even that module relies on Cron i.e. the trigger fires at every cron run. Its worth a try. Let me know if you need additional info. Apr 23, 2018 at 5:34

1 Answer 1


Running cron every minute is perfectly acceptable. But if you really want a different solution you could (for example) create a Drush command to do what you want and then call that every minute with something like Jenkins or RunDeck. If you really need this command to run at the exact times users specify and only at those times, then you could write code to publish out the time (and other contextually relevant info) to some external system which is constantly running with some Daemon.

This solution will work but it is:

  • a) hard because there is a lot of custom work to do
  • b) tricky because you have to worry about publishing, but you also have to worry about updates and deletes in case your users ever make changes to the time or the contextually relevant data
  • c) unnecessary since frequent cron runs sounds like it can solve your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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