2

I have a site which requires periodic tasks to be done (sending content update notification / subscription, etc); which are configured on cron run. The cron run is setup to run after every "3 hours" at admin > config > system > cron.

I (user 1) did not visit the site for 10-12 days, while some of the other authenticated users did some activity like commenting / adding content. I have enabled notification emails whenever any user adds / edits any content or comment.

Last night when I logged into the site, I received notifications for the period of 10-12 days (period for which I did not log in to the site). While, as per the expected behavior I should have been receiving the notifications on the cron run after the user activity.

I checked to see the logs, and during this days I can see only the following message under the type "cron"

Attempting to re-run cron while it is already running.

And strangely, I could see

Cron run completed.

just before 5 secs of the message:

Session opened for admin-user.

So, it is clear that I did not receive the notifications because the cron did not run during this period of time.

So, my question is why did the cron not run for these days? What is the exact event which triggers cron to start running? I understand that in Drupal 7 cron.php is called along with a token value to run the cron. But who / what does this call? Or do the Admin users need to log into trigger this action?

UPDATE: The site is on a dedicated server owned by the company. I have access to it as root user. And obviously don't have a cpanel to it ;-) And I have not set any other application to like crontab? Do I need to do so? If so how?

2
  • 2
    cron.php will be invoked with help of crontab in a linux environment, similar schedulers can be used on other OS. Time at which it is triggered can be controlled from crontab
    – GoodSp33d
    Dec 20, 2012 at 12:00
  • @2-Stroker Thank you. Could you help me by elaborating the working a bit more?
    – AjitS
    Dec 20, 2012 at 12:31

1 Answer 1

3

So, my question is why did the cron not run for these days? What is the exact event which triggers cron to start running?

Poormans cron is D7 default cronjob handler, which invokes cron hooks. But it depends on traffic, when a user visits a page it will check last time at which cron was run, and schedule it to run if needed according to interval set.

Summary : This is not reliable if cron has to be run daily. To do so open up crontab from terminal (crontab -l will list the jobs, crontab -e will let you edit jobs) Ex:

0 0 * * * wget -O - -q -t 1 http://<yoursite>/cron.php?cron_key=<yourkey>

Will schedule cron job @midnight daily.

Your Answer

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

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