Warning: 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.
You will want to execute your
cron/cron_exec.php script on a regular basis.
First, you’ll need to know exactly where this script resides on your system. You could try using this command:
Note: if you have just uploaded the script it will not be found. In this case type
updatedb to refresh your locate database.
Once you know where the script file is, you need to use the PHP interpreter in order to run it.
Note: PHP comes in different flavors: Apache module, CGI module, CLI, etc. The preferred version to use here is the CLI (Command Line Interface).
You could try using this command:
If you’re set up correctly you should get something like:
PHP 4.3.10-16 (cli) (built: Aug 24 2005 20:25:01)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
(cli) after the version number?
If you get an error, you may not have the PHP CLI package installed. Under DEBIAN, the package you want to install is
If you get a lot of HTML, then you’re running PHP but not the CLI version. This is not optimal but may work anyway.
Now try running the cron_exec from the command line:
You may get an error about MySQL needing to be enabled. This must be done in php.ini (again, location may vary, use
locate php.ini). Un-comment the following line then try running the command again:
When the script runs, it either outputs a lot of info about the scheduled job it executes, or when there is no job to execute, it would simply output something like:
There is no task to execute yet.
Now that you can run the script from the command line, let’s automate it…
Edit the file
/etc/crontab and add the following line:
* * * * * root /usr/bin/php /your/own/path/cron/cron_exec.php >/dev/null 2>/dev/null
Note: root is the user under which the script will be run, you may want to change that.
>/dev/null 2>/dev/null discards all messages and error messages, you may want to redirect those to a file for debugging purposes.
This is for advanced users only.
If you are running multiple instances of b2evolution on the same server you may wish your system to automatically run new cron_exec scripts as you install them.
One solution would be to place this into
# Get list of crons we can run:
# Loop though all sites
for Cron in $CronList
And call it like this in
* * * * * www-data /usr/local/bin/evo-cron