How to force a Cron Job to start ahead of time?

webnoob picture webnoob · May 14, 2011 · Viewed 14k times · Source

I have just provided a way to let my users stop their Cron Task. The cron is set up to run every 5 minutes to make sure its up and running BUT I would like to be able to start the cron job manually if the user clicks the restart button.

Is there any way to force the cron to start as apposed to waiting for its next 5 minute cycle?

I am using PHP on CentOS.

Answer

Steve Kehlet picture Steve Kehlet · May 14, 2011

You could just run whatever's being run in cron for you. Or.. you could set cron to run the script every minute (a little better), but only run every 5 unless a flag file exists (which you created, and now remove).