Running maintenance

Note: This article is for an old version of OpenX.

The latest OpenX documentation can be found at the following URLs:

To function correctly, OpenX runs a regular maintenance script (the default period is hourly) which:

  • produces statistics from the previous hour (or other maintenance period)
  • activates and deactivates campaigns
  • recalculates banner delivery priorities
  • sends email reports

You can run the maintenance script in two ways:

  • built-in automatic maintenance
  • schedule a regular task to run the maintenance script

OpenX will continue to run if the maintenance script is not executed. However, if the maintenance script does not run campaigns with an expiry date or a fixed number of impressions will be delivered more often than desired. If you are having problems delivering these types of campaigns, check that the maintenance script is running correctly. When the maintenance script runs, all outstanding raw data is processed.

Built-in automatic maintenance

The OpenX built-in automatic maintenance script has several advantages:

  • outstanding maintenance tasks are triggered by banner delivery
  • enabled by default on new installations
  • no need to create scheduled tasks

Automatic maintenance waits for five minutes after the scheduled maintenance task was due to run. This delay ensures that any manually-scheduled maintenance has time to complete. With automatic maintenance you can:

  • enable and disable automatic maintenance on the Global Settings > Maintenance page.
  • view the current maintenance status on the Global Settings > Maintenance page.
  • view the log of maintenance runs on the My Account > User Log page.

Scheduled maintenance

Scheduling maintenance as a task is more flexible than automatic maintenance. You can start the maintenance script by:

  • executing a locally run script
  • calling the script url on the web server

Scheduling tasks on Linux and Unix

On Linux, BSD, Solaris or MacOSX you can use the cron daemon to automatically run the maintenance script. In most cases you will need shell access to your server to add cron tasks, using the following commands:

  1. Log on to your server, then use the following command to export your existing scheduled tasks to a text file:
    crontab -l > cron.txt
  2. In a text editor, add one of the following entries to the cron.txt file:
    • If your server supports PHP CLI (Command Line Interface) - recommended
      0 * * * * /path/to/php /path/to/openx/scripts/maintenance/maintenance.php www.mydomain.com
    • If your server supports wget:
      0 * * * * wget \-q \-O /dev/null [http://www.example.com/Openx/maintenance/maintenance.php]
    • If your server supports fetch:
      0 * * * * fetch \-o /dev/null [http://www.example.com/Openx/maintenance/maintenance.php]
    • If your server supports lynx:
      0 * * * * lynx > /dev/null \-dump [http://www.example.com/Openx/maintenance/maintenance.php]
  3. When you have finished editing the cron.txt file, use the following command to import it into the cron daemon:
    crontab cron.txt

Time zone setting in PHP 5.0

If running PHP release 5.0 or lower, for time zones to work correctly you must set up the TZ environment variable when setting up maintenance via cron. This is the same process you wouuld follow in the Apache configuration.

This task requires an entry similar to the following in the crontab file:

TZ='Europe/Berlin'

1 * * * * /path/to/php /path/to/openx/scripts/maintenance/maintenance.php www.mysite.com

If you do not enter this setting it is likely that time zones will work correctly for half the year, but not in Summer Time. 

With PHP release 5.1 or higher this setting is not required, as the setting is managed by the php.ini file.