Windows Scheduled Task Setup
So, you want to set your b2Evolution Scheduler to run on a regular basis using your Windows server, eh? Follow along as we explore the magic of the Windows Task Scheduler service.
First, you’ll need to know exactly where this script resides on your system. If you don’t know already (maybe you should call that child/cousin/uncle/brother/grandmother now?), you can find it by clicking
Start -> Search -> For Files and Folders from the task bar and entering
cron_exec.php as the search criteria. These instructions will assume you found it at:
Next, we need to know where PHP is installed. You definitely have it installed already if your server is serving out delicious b2Evolution pages, so fret not. You can do that search thing again, this time entering
php.exe as the search term. These instructions will assume you found it at:
PHP comes in many different flavors: Apache module, CGI module, Command Line module (CLI), etc. The preferred version to use here is the CLI version. Lets test it. Click Start -> Run… from the task bar and enter
cmd. This will open the Windows command prompt. At the command line (it should look like
C:\>) enter the full path to your
php.exe file followed by
-v (that’s [space][minus][lowercase v]) and hit Enter. It should look something like this:
And return something like this:
PHP 5.1.2 (cli) (built: Jan 11 2006 16:40:00) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
If you’re lucky, you’ll find that
cli designation after the version number. If not (maybe you see a bunch of HTML, or just no CLI designation) this may still work but you should try to find the CLI executable of your PHP installation. You can check the PHP website (http://www.php.net) for details on your specific version of PHP.
For the purposes of this tutorial, we’ll assume that every thing worked peachy and that you’re using the CLI version.
Now lets make sure that cron_exec.php script will play nicely with your php.exe file. Go back to your command prompt and enter:
And it should result in the simple message:
There is no task to execute yet.
If you see any other messages or if you just get a bunch of HTML, read through these and correct what ever is wrong. If you continue to have trouble, try posting a question in the b2Evolution forums http://forums.b2evolution.net/. For instance, the first time around I got this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>b2evolution is not configured yet</title> </head> <body> <div style="background-color:#fee; border: 1px solid red; text-align:center; "> <p>This is b2evolution version 1.8-beta.</p> <p><strong>You cannot use the application before you finish configuration and installation.</strong></p> <div style="font-weight:bold; color:red;">Base configuration is not done! (see /conf/_basic_config.php)</div> <p>Please use the installer to finish your configuration/installation now.</p> <p>On most installations, the installer will probably be either <a href="install/index.php">here</a> or <a href="../install/index.php">here</a>... (but I can't be sure since I have no config info available! :P)</p> </div> </body> </html>
I fixed the problem by going through the installer, then ran the command again and got the expected message.
The final step will be to set the script to run automagically. For starters, we need to get out our Task Scheduler. From the task bar, click Start -> Programs -> Accessories -> System Tools -> Scheduled Tasks. You may not have any scheduled tasks defined yet, in which case you’ll see only an icon to add a scheduled task, but don’t click it! I know it’s tempting, but that opens one of those fancy "wizards" and we would rather do things the non-wizard way. Proceed with the following steps:
- Right-click on an empty spot in the Scheduled Task window and select New -> Scheduled Task (Also accessible via File -> New -> Scheduled Task)
- Name the new task (How about "Bill"? He looks like a Bill, doesn’t he? "Mr. B. Evolution, II" It sounds so regal.)
- Double-click the new task to open the properties window (or File -> Properties)
- Under the Task tab, enter the same command that you used to test the script above. For instance, enter:
- Go to the Schedule tab and enter when and how often the task should run. The schedule defaults to run once daily and should be fine for basic usage, but feel free to tweak as needed.
- The rest of the fields can be left as-is, unless you’re an ace and know what you’re doing.
- Click OK and we’re done!
You’ll probably want to run the task once to make sure everything goes OK. First, change the view of the Scheduled Task window to show all details (View -> Details). Next, right click the task and select Run (or File -> Run…). Watch the Last Run Time column - when it changes from Never to today’s date the task has finished running. Now look in the Last Result column. You should see the code "0x0", which means the task completed successfully. If you see any other code, click Advanced -> View Log in the menu bar and look for any errors reported for your task. Fix any problems and test again until you are successful.
That should do it!
Created by • Last edit by on Aug 19, 2019