Powered by MediaWiki
Personal tools

Set up a cpanel cron job

From b2evolution manual

Jump to: navigation, search

This solution isn't as good as setting up a Linux cron job by far, but we mention 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 jobs" section and create a cron job here.

You are going to set up a command that will be run every minute, every hour, every day, every month... or less if you choose too.

The "magic" command to type in is:

 wget -q -O cron_exec.html http://b2evolution.net/cron/cron_exec.php

wget will simulate a browser hitting the cron_exec.php page each time it is called (once a minute).

wget will also save the result (the HTML you would normally see in your browser) into a file. By default it creates a new file every time. I don't know where on the server this will happen, but that's not something you want to happen. This is why we have included the option "-O cron_exec.html". I will make sure the output always goes to the same file named cron_exec.html.


In cpanel, you can also enter an email address where the cron output will send you an email about what happened each time it runs. This is a perfect way to get a new email every minute of the day but it can get boring quite fast. So if you can, leave the email address empty except maybe for debugging.

Just in case your own version of cPanel doesn't allow for an empty email address, we have included the option "-q" in the command above. It means "quiet"; in other words: "don't talk to me, don't generate an email".

You can also use this if allowed by your host:

 php /path/to/your/blog/cron/cron_exec.php > /dev/null

It will tell cron to run /cron/cron_exec.php as a php by using the command 'php'. If the shortcut does not work for your host, you can use /usr/bin/php or /usr/local/bin/php

The '> /dev/null' tells the cron to dump all non-error messages to /dev/null which is like a 'blackhole'. You will never see these non-error messages again.