Maintenance server

From Wikitech
Jump to navigation Jump to search

Maintenance servers are where we run scheduled and ad-hoc command-line scripts relating to MediaWiki.


As of March 2023, the servers are:

We manage the scheduling in Puppet (puppet: profile/mediawiki/maintenance.pp), where we declare which scripts to run, when and how often, and what wikis to run them on. As of 2020, the scripts are run via systemd timers. Previously, we used cron to run the maintenance jobs.

To run maintenance scripts on the Beta Cluster you need to connect to the equivalent servers on deployment-prep. E.g.:


Run a maintenance script on a wiki

When running a long-running maintenance script, consider using screen.

To run a maintenance script, log into the active maintenance server.

Use the mwscript command-line utility:

mwscript run.php --wiki dbname scriptname.php

The above command will run the script scriptname.php located in the /maintenance directory of the specified wiki's php directory.

You can also use a path relative to root of the MediaWiki installation, for example to run a script from an extension rather than core. It is recommended that in this case you first browser to one of the MediaWiki directories to allow for tab completion:

$ cd /srv/mediawiki/php-1.xx-wmf.xx/
$ mwscript run.php --wiki dbname extensions/MyExtension/maintenance/scriptname.php 

If you need to pass parameters to your maintenance script, you can add them to the end. You may also want to explicitly declare the database parameter to avoid confusion:

mwscript run.php --wiki=enwiki scriptname.php --days=1

In this case, the wiki parameter is handled by mwscript and the 'days' parameter is handled by scriptname.php. The "wiki" must be in wikiversions.json so the maintenance script machinery can figure out what MediaWiki version it is running.

Many maintenance scripts are used to run heavy database queries; remember to check the replication lag and other possible byproducts.

See also