Setting up the Scheduler (cron job)
The Scheduler is the b2evolution feature that allows to run Scheduled Jobs / Scheduled Tasks automatically at predefined times or intervals.
This allows to properly maintain and prune the large database tables, to keep the Antispam Blacklist automatically up to date or to send Users reminder emails when they have unread messages for example… See Scheduled Tasks Reference for a list of available tasks to be scheduled.
At installation, b2evolution is set up with a list of Scheduled Jobs that will work fine for most websites. See Scheduled Jobs List to see a default schedule.
Now, b2evolution is written in PHP, which means it cannot actually wake up all by itself. It needs the operating system waking it up. This is typically done with what is called a "cron job".
There are several methods to set up such a "cron job". Basically, you need to make sure
/cron/cron_exec.php is called on a regular basis, such as once every few minutes.
Here is a list of options to achieve this, in order of preference (first is best):
- Set up a Linux cron job, i-e: let Linux call php on a regular basis
- Set up a cPanel cron job, i-e: let "cPanel’ call the scheduler through the webserver on a regular basis
- Set up a Windows Scheduled Task, i-e: let Windows call cron_exec.php on a regular basis
- or Set up a web watch dog that will ping
- or Open that page in a browser and let it refresh itself.
How often should the cron job run?
Unless your web host doesn’t allow you to do so, we recommend running the cron job that wakes up b2evolution every 1 to 5 minutes.
Remember, this is just a very small wake up call. When woken up, b2evolution’s Scheduler will check if there is a pending Scheduled Job that has reached the time to be executed.
- If yes, it will execute that task, exit and go back to sleep. The time this takes depends on the task being executed.
- If no, it will immediately exit and go back to sleep. This takes virtually no time at all. This has a lighter load on the system than a typical request from Google-bot or an attempt from a spam-bot to post a comment on your site.
Having a frequent wake-up call (i-e: a cron job that executes often), will allow the b2evolution Scheduler to execute its Scheduled Jobs in a timely manner.
Linux Cron Job SetupWarning: The following assumes you have your own Linux server with root access. Blindly following this procedure may lead to breaking your Linux setup. DO NOT do this if you don’t understand it. Use this page only as a guideline. Running the…More »
cPanel Cron Job SetupThis solution isn’t as good as setting up a Linux cron job by far, but we mentioned it since cPanel is very widespread and somewhat easier to set up. So if your host uses cPanel as a web configuration interface, you can go to the "cron…More »
Windows Scheduled Task SetupWarning: The following assumes you have administrative access to the Windows server where b2Evolution is served from and that the Task Scheduler service is enabled. These instructions are valid for Windows Server 2000 and 2003. They will probably work…More »