Difference between revisions of "SUNScholar/Daily Admin/3.X"

From Libopedia
Jump to navigation Jump to search
m
 
(13 intermediate revisions by the same user not shown)
Line 8: Line 8:
  
 
==Step 2. Create "dspace" user crontab==
 
==Step 2. Create "dspace" user crontab==
The "dspace" user has to perform tasks automatically at regular intervals, such as sending out subscription emails.
 
 
On a Linux/Unix system this is easy to accomplish using the "cron" functionality.
 
 
 
Edit the crontab, by typing the following in a terminal:
 
Edit the crontab, by typing the following in a terminal:
  
Line 28: Line 24:
 
# Deliver cron email to system administrator
 
# Deliver cron email to system administrator
 
MAILTO="root"
 
MAILTO="root"
 
#Ensure that HOME is set properly for our service
 
HOME=/home/dspace
 
 
#Add Java to PATH (for all DSpace cron jobs)
 
#Also add all major 'bin' directories
 
PATH=/usr/bin:/bin:/usr/local/bin
 
 
#Specify default Java options (for all DSpace cron jobs)
 
JAVA_OPTS=-Xmx512M -Xms512M -Dfile.encoding=UTF-8
 
  
 
##########
 
##########
Line 66: Line 52:
 
# (Creates image thumbnails, indexes full text, and  
 
# (Creates image thumbnails, indexes full text, and  
 
# performs any automated format conversions)
 
# performs any automated format conversions)
0 2 * * * $HOME/bin/dspace filter-media > $HOME/log/media-filter.log 2>&1
+
0 2 * * * $HOME/bin/dspace filter-media -n -v > $HOME/log/media-filter.log 2>&1
  
 
# 3:00AM
 
# 3:00AM
Line 73: Line 59:
  
 
# 5:00AM
 
# 5:00AM
# Check for items to release from embargo in DSpace.   
+
# Check for items to release from embargo in DSpace.
0 5 * * * $HOME/bin/dspace embargo-lifter > $HOME/log/embargo-release.log 2>&1
+
# !!!It is good idea to regularly check the file $HOME/log/embargo-release.log for warnings!!!  
 +
0 5 * * * $HOME/bin/dspace embargo-lifter -v > $HOME/log/embargo-release.log 2>&1
  
 
# 6:00AM
 
# 6:00AM
Line 121: Line 108:
 
0 2 1 * * find $HOME/*.bak-*-* -maxdepth 0 -type d -mtime +30 -exec rm -rf {} \;
 
0 2 1 * * find $HOME/*.bak-*-* -maxdepth 0 -type d -mtime +30 -exec rm -rf {} \;
 
</pre>
 
</pre>
 +
 +
Save and exit the file.
 +
 +
==System Log==
 +
To enable logging of cron events, edit the following file:
 +
sudo nano /etc/rsyslog.d/50-default.conf
 +
Enable the cron log, see example below:
 +
<pre>
 +
#
 +
# First some standard log files.  Log by facility.
 +
#
 +
auth,authpriv.*                /var/log/auth.log
 +
*.*;auth,authpriv.none          -/var/log/syslog
 +
cron.*                          -/var/log/cron.log
 +
</pre>
 +
 +
{{NANO}}
 +
 +
Now restart the syslog service as follows:
 +
sudo service rsyslog restart
  
 
==References==
 
==References==
 
*https://wiki.duraspace.org/display/DSDOC3x/Installation#Installation-'cron'Jobs
 
*https://wiki.duraspace.org/display/DSDOC3x/Installation#Installation-'cron'Jobs
 +
 +
[[Category:System Administration]]
 +
[[Category:Installation]]
 +
__NOTOC__

Latest revision as of 23:59, 9 June 2016

Back to Daily Admin

Step 1. Login

http://wiki.lib.sun.ac.za/index.php/SUNScholar/Prepare_Ubuntu/S01

Click on the link above to find out how to login to the server and then return here.

Step 2. Create "dspace" user crontab

Edit the crontab, by typing the following in a terminal:

su - dspace
crontab -e

If asked to select an editor, choose nano


NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Sample crontab

####################################
# Initialize Environment Variables #
####################################
# Deliver cron email to system administrator
MAILTO="root"

##########
# Hourly #
##########
# Regenerate System Sitemaps every 8 hours
# at 3 minutes past the hour
3  0,8,16 * * * $HOME/bin/dspace generate-sitemaps > /dev/null

# Update item counts every hour
@hourly	    $HOME/bin/dspace itemcounter > /dev/null

###########
# Nightly #
###########
# 12:30AM
# Run DSpace statistical analysis tools (12months takes approx 40secs)
30 0 * * * $HOME/bin/dspace stat-general  > /dev/null
35 0 * * * $HOME/bin/dspace stat-monthly  > /dev/null

# 1:00AM
# Generate DSpace statistical analysis reports
00 1 * * * $HOME/bin/dspace stat-report-general  > /dev/null
05 1 * * * $HOME/bin/dspace stat-report-monthly  > /dev/null

# 2:00AM
# Run the DSpace media filter scripts and save all output to a log file
# (Creates image thumbnails, indexes full text, and 
# performs any automated format conversions)
0 2 * * * $HOME/bin/dspace filter-media -n -v > $HOME/log/media-filter.log 2>&1

# 3:00AM
# Update simple, advanced search and browse indexes
0 3 * * *  $HOME/bin/dspace index-update > /dev/null

# 5:00AM
# Check for items to release from embargo in DSpace.
# !!!It is good idea to regularly check the file $HOME/log/embargo-release.log for warnings!!!  
0 5 * * * $HOME/bin/dspace embargo-lifter -v > $HOME/log/embargo-release.log 2>&1

# 6:00AM
# Run XOAI incremental import (and optimization)
0 6 * * * $HOME/bin/dspace oai import -o > /dev/null

# 6:30AM
# Cleanup Web Spiders from DSpace Statistics Solr Index
# -i deletes all spiders matched by IP address, DNS name or Agent name
30 6 * * * $HOME/bin/dspace stats-util -i > /dev/null

# 7:00AM
# Optimize Discovery Solr Index
0 7 * * * $HOME/bin/dspace update-discovery-index -o > /dev/null

# 7:30AM
# Optimize DSpace Statistics Solr Index
30 7 * * * $HOME/bin/dspace stats-util -o > /dev/null

# 8:00AM
# Send out DSpace subscription emails
# (This alerts users of newly deposited items of interest)
0 8 * * * $HOME/bin/dspace sub-daily > /dev/null

##########
# Weekly #
##########

###########
# Monthly #
###########
# 12:01AM
# Remove all DSpace log files which are more than 30 days old
# on the first of every month
01 0 1 * * find $HOME/log/*.log.* -mtime +30 -exec rm {} \;

# 1:00AM
# Completely remove any deleted bitstreams in DSpace
# on the first of every month
0 1 1 * * $HOME/bin/dspace cleanup > /dev/null

# 2:00AM
# Delete any ~/config/*/*.old files more than 30 days old (created by "ant update")
0 2 1 * * find $HOME/config -name "*-*-*.old" -mtime +30 -exec rm {} \;
# Delete any ~/*.bak-*-*/ directories more than 30 days old (created by "ant update")
0 2 1 * * find $HOME/*.bak-*-* -maxdepth 0 -type d -mtime +30 -exec rm -rf {} \;

Save and exit the file.

System Log

To enable logging of cron events, edit the following file:

sudo nano /etc/rsyslog.d/50-default.conf

Enable the cron log, see example below:

#
# First some standard log files.  Log by facility.
#
auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
cron.*                          -/var/log/cron.log

NANO Editor Help
CTL+O = Save the file and then press Enter
CTL+X = Exit "nano"
CTL+K = Delete line
CTL+U = Undelete line
CTL+W = Search for %%string%%
CTL+\ = Search for %%string%% and replace with $$string$$
CTL+C = Show line numbers

More info = http://en.wikipedia.org/wiki/Nano_(text_editor)


Now restart the syslog service as follows:

sudo service rsyslog restart

References