Displaying 1 - 3 of 3

How to run a cronjob every X seconds in cron

Running a Unix command every few seconds is not something Vixie cron can deal with natively because its smallest level of granularity is the minute. It can easily run a script every minute. But to run a cron job every second, or every 5 seconds, or even every 30 seconds, takes a few more shell commands.

As mentioned, a command can be run every minute with the crontab time signature of * * * * * (5 stars) followed by the command.

Had we wanted to run the command every 5 minutes, we can do that with /5 on the minute field: */5 * * * *....

Debugging and troubleshooting cron jobs

Usually when I have mysterious problems with a new crontab, it's that I'm not getting any results or output as expected, as if the command didn't run at all. Almost always, the newly added line to crontab was run. What did it do, what was the output, when did cron run? What should we check for?

  • Rarely, there is a problem in the time/data fields. The fields are:

    • minute
    • hour
    • day of month
    • month
    • day of week
    • then the command

    So make sure there are exactly 5 numbers or stars () before the command. Then

  • ...

Solve mysterious Drupal initial page load delay with cron

Sometimes you'll visit your Drupal site in the morning, or after logging in as admin for the first time in awhile, and the page will take forever to load, more than 30 seconds, even longer. (First, if you're using Cloudflare CDN, it could be a problem with their servers not sending the end of the page html when it's finished and thus causing the browser to hang for a long time.)

The main cause of this kind of page load lag is Drupal's cron task! There are two ways that Drupal will run cron. The first is when you trigger it externally (by pinging the cron.php url,...