Automating your maintenance

From EPrints Documentation
Revision as of 11:38, 3 February 2009 by Tmb (talk | contribs) (Alerts)
Jump to: navigation, search

Crontab

Crontab is the unix command which allows you to execute commands at predetermined times:

Creating a crontab

The best way to do this is to use "cron" which is an integral part of most UNIX systems.

To set up cron, run (as the eprints user):

 eprints@host% crontab -e

You have to add one set of crontab entries per repository.

The basic crontab syntax is as follows and should be contained in a file.

 *  *  *  *  *  command to be executed
 -  -  -  -  -
 |  |  |  |  |
 |  |  |  |  +----- day of week (0 - 6) (Sunday=0)
 |  |  |  +------- month (1 - 12)
 |  |  +--------- day of month (1 - 31)
 |  +----------- hour (0 - 23)
 +------------- min (0 - 59)
 
 Thanks to AdminsChoice for this diagram.

Generate Scripts

Outlined in Generate Scripts. It is advisable to also crontab these scripts to run nightly.

For example (where $EPRINTS_ROOT is the root directory of your EPrints install):

 # 00:00 every morning at midnight
 0 1 * * * $EPRINTS_ROOT/bin/generate_static repository-name
 # 01:00 every morning at 1am
 0 1 * * * $EPRINTS_ROOT/bin/generate_views repository-name
 # 02:00 every morning at 2am
 0 2 * * * $EPRINTS_ROOT/bin/generate_abstracts repository-name

Alerts

To automate sending out these alerts you must add some entries in the crontab (as for views). You need one set of these per archive.

For example (where $EPRINTS_ROOT is the root directory of your EPrints install):

 # 00:15 every morning
 15 0 * * * $EPRINTS_ROOT/bin/send_alerts repository-name daily
 # 00:30 every sunday morning
 30 0 * * 0 $EPRINTS_ROOT/bin/send_alerts repository-name weekly
 # 00:45 every first of the month
 45 0 1 * * $EPRINTS_ROOT/bin/send_alerts repository-name monthly

Note the spacing out so that all 3 don't start at once and hammer the database. You may wish to change the times, but we recommend early morning as the best time to send them (midnight-6am).

Embargoed documents

Automatically remove access restrictions on embargoed documents when the embargo expires.

For example (where $EPRINTS_ROOT is the root directory of your EPrints install):

 # 01:15 every morning
 15 1 * * * $EPRINTS_ROOT/bin/lift_embargos repository-name