Difference between revisions of "Automating your maintenance"

From EPrints Documentation
Jump to: navigation, search
 
Line 1: Line 1:
 +
==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)
 +
 +
==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==
 
==Alerts==

Revision as of 14:19, 3 September 2007

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)

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).