Automatic maintenance
| Note: This article is for an old version of OpenX. The latest OpenX documentation can be found at the following URLs: |
Openads 2.0 uses a special maintenance script to activate
campaigns, recalculate priorities, clean up statistics and send out advertiser
reports. The maintenance scripts needs to run every hour for the application to
function correctly. There are are a number of ways to automatically schedule
the maintenance script, some of which are described below.
Built-in Automatic Maintenance
On installation, Openads' built-in automatic maintenance is enabled by
default. This is a particularly useful feature as, according to your needs, you
don't have to create a Windows scheduled task or UNIX cron job. Each time
banners are delivered to your website, the built-in automatic maintenance
carries out the required maintenance tasks, including updating your statistics.
You can combine automatic maintenance with your own scheduled tasks if
required, or you can disable Openads' automatic maintenance, without affecting
your own scheduled maintenance tasks.
When you set up your own scheduled maintenance, automatic maintenance (if
enabled) still plays its part. In that case, delivering banners triggers
automatic maintenance when maintenance has not run in the last hour, or when it
hasn't run in the current hour when the current time is later than
five minutes past the hour - this five-minute period allows any scheduled
maintenance to complete.
You can view the current maintenance status by checking the
Settings>Maintenance screen, then choosing the Maintenance
option from the drop-down list. You can view the log of maintenance runs in
Settings>User Log, where automatic maintenance runs are
identified by a separate icon.
Scheduled Maintenance
The most common way to schedule a task on Linux and UNIX based
servers is to use the cron daemon. On Windows 2000 and XP servers there is a
graphical interface to schedule tasks or you can use the at command. If for
some reason you can't use these tools you could opt to use an external cron
service, or use the cron emulator that came with the phpAdsNew package. The
last two options are less reliable, if you can try to avoid using these.
If for some reason the scheduled task didn't run one particular
hour there shouldn't be any major problems. Running without the maintenance
script for longer period will have an effect on the functionality of phpAdsNew.
For example, if the maintenance script isn't running, phpAdsNew won't activate
new campaigns and the advertiser reports won't be send. One more very important
side effect is that phpAdsNew won't recalculate the priority, which means high
priority campaigns and campaigns that have both an expiration date and a fixed
number of impressions will be delivered more often than is wanted. If you are
having problems with the delivery of these types of campaigns always check if
the maintenance script is running first.
If the maintenance script hasn't run in over 24 hours a message
will be displayed as soon as you log into the administrator interface. This
message cannot be disabled, the only way to prevent this message from being
shown is to set up the maintenance task correctly.
Scheduling tasks on Linux and UNIX based servers
If you are using Linux server or a Unix
based server such as BSD, Sun or MacOS X you can use the cron daemon to
automatically run the maintenance.php file. You can edit your scheduled tasks
using the crontab utility. If you don't have permission to use crontab, please
contact your service provider or server administrator.
In most cases you will need shell access to
your server to add a new scheduled task. After using telnet or ssh to login to
your server use the following command to export your existing scheduled tasks
to a text file:
crontab -l > cron.txt
After exporting your existing tasks to a
text file you can use any text editor you want to add tasks. Because every
server or service provider is different it is not easy to provide a way to
schedule tasks that will work on every server. Depending on the configuration
of your server you can use one of the following tools to actually run the
maintenance file: curl, fetch, lynx or wget. To find out which is supported by
your server simply type the name of the tool on the command-line. If you get a
message 'command not found' the tool isn't supported on your server.
Based on which tool your server supports
add one of the following lines to the cron.txt file:
# if your server supports curl:
0 * * * * curl -s -o /dev/null
http://www.server.com/phpAdsNew/maintenance/maintenance.php
# if your server supports fetch:
0 * * * * fetch -o /dev/null
http://www.server.com/phpAdsNew/maintenance/maintenance.php
# if your server supports lynx:
0 * * * * lynx > /dev/null
-dump
"sect2">http://www.server.com/phpAdsNew/maintenance/maintenance.php
# if your server supports wget:
0 * * * * wget -q -O /dev/null
http://www.server.com/phpAdsNew/maintenance/maintenance.php
After you changed the cron.txt file and
added the line for the tool you want to use, you need to import the file back
again into the cron daemon. To do this type the following command on the
command-line:
crontab cron.txt
Using cPanel to schedule maintenance tasks
on Linux and UNIX based servers
An alternative method of creating a cron job on
Linux/UNIX servers is by using cPanel. The general procedure is as
follows:
- In cPanel, click Cron jobs in the main display of the interface;
- Click Advanced (Unix style) to access the Cron
Manager; - Enter an email address to which reports can be sent (effectively the output
of the command run by the cron job) in the field provided; - Select the frequency of the job in the boxes provided; for example:
- Minute : 2
- Hour : *
- Day : *
- Month : *
- Weekday : *
In this example, 2 minutes past the hour is chosen simply to avoid
the typically 'busy' time for the server on the hour.
Now enter the command you wish the cron job to run; for
example:
curl -s -o /dev/null
http://the_proper_domain/maintenance/maintenance.php
(where the_proper_domain indicates your full Openads
url)
Don't forget to save your changes to set up your cron job. Note that this
procedure does not apply precisely to all versions of cPanel and there may be
some variations in your particular version.
Scheduling tasks on Windows 2000 and XP
servers
If you are using a Microsoft Windows 2000
or XP server you can use the Scheduled Tasks to automatically run the
maintenance file. However there is no standard tool available to actually run
the maintenance file.
Downloading wget
The first thing to do is to download wget,
which is a command line utility to get the contents of a file stored on a web
server. Wget is available for all kinds of operating systems, including
Windows. After you have downloaded the zip file you need to copy the wget.exe
file to the directory where Windows is installed. Wget isn't part of phpAdsNew
and needs to be downloaded seperately. Up-to-date download locations are listed
on the wget homepage: http://www.gnu.org/software/wget/wget.html
Creating a batch file
The next step is creating a small batch
file which will call the wget utility with the correct parameters. This file
can be executed as a Scheduled Task later on. You can use Notepad to create a
new file and add the information below, then save the file as phpads.bat. You
can save the file anywhere you like, but it is wise to keep it in a location
that isn't going to change, and isn't accessible by the web server. Also make
sure to specify the correct URL inside the batch file, the URL below is just an
example.
|
The next step would be to actually add a
new Scheduled Task. You can find all Scheduled Tasks inside a directory inside
the Control Panel.
|
Now click on Add Scheduled Task. The wizard
will begin and after you click on Next it will ask you for the program to run.
Just click on Browse... and select the batch file you just created. Now you
need to give this Scheduled Task a name and select to perform this task
daily.
|
Click on Next and set the Start time to
0:00 and choose to perform this task every day.
If you click Next the wizard will ask you
for your username and password.
|
After you supplied your username and
password click on Next. Make sure to select Open advanced properties...,
because you will need to make some modification to this task. Now click on
Finish.
|
To make sure this task runs hourly you will
need to go to the Schedule tab and select the Advanced... button. Now check
Repeat task and make sure the task is repeated every hour. Also select the
radio button Time and set the value to 23:59. Now click OK to close this
dialogbox and click Apply to save all settings.
|
server
If your server doesn't support Scheduled
Tasks or cron jobs, it is still possible to run the maintenance file every hour
automatically, by using an external cron server.
|
Cronservices.com
For just $9.95 a year, cronservice.com
allows you to add as many scheduled tasks as you want by using a simple web
based interface. After logging in at cronservices.com, you need to specify
which task you want to run by clicking the Add new job button.
If you want to run a job hourly you need to
select all hours. Don't select a date, day of week or month. Then enter the
full URL of the maintenance file in the Script URL field. For example: if you
installed Openads on http://www.server.com/Openads, the full URL would be
http://www.server.com/Openads/maintenance/maintenance.php. After entering a job
name you can click on the Insert button.
running
The maintenance task if very important for
the functionality of Openads. Without running the maintenance task every hour
many different problems can occur. Because of this it is important to check
whether the maintenance task is running properly.
| If you log in to phpAdsNew and the maintenance task hasn't ran in 24 hours the |
Apart from the warning dialog displayed
above, there is another way to see if the maintenance task is running properly.
If you have enabled the option Log hourly priority calculations on the
Administrator settings page a log of the priority calculations will be stored
in the User log. If this option is enabled, but there are no logs visible in
the User log the maintenance task is probably not running correctly.

RSS
Twitter
Facebook
FriendFeed