vacuum the DB every night
[myplc.git] / plc.d / crond
1 #!/bin/bash
2 #
3 # priority: 900
4 #
5 # Configure cron jobs
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10 # $Id: crond,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
16
17 case "$1" in
18     start)
19         MESSAGE=$"Starting crond"
20         dialog "$MESSAGE"
21
22         if [ "$PLC_MAIL_ENABLED" = "1" ] ; then
23             MAILTO=$PLC_MAIL_SUPPORT_ADDRESS
24         else
25             MAILTO=
26         fi
27         cat >/etc/cron.d/plc.cron <<EOF
28 SHELL=/bin/bash
29 PATH=/sbin:/bin:/usr/sbin:/usr/bin
30 MAILTO=$MAILTO
31 HOME=/
32
33 # minute hour day-of-month month day-of-week user command
34 */5 * * * * root gen-slices-xml-05.py
35 */15 * * * * root gen-sites-xml.py
36 */15 * * * * root gen-static-content.py
37 5 5 * * * root vacuumdb -U postgres --all --analyze --quiet
38 EOF
39
40         # Run them once at startup
41         gen-slices-xml-05.py
42         check
43         gen-sites-xml.py
44         check
45         gen-static-content.py
46         check
47         vacuumdb -U postgres --all --analyze --quiet
48         check
49
50         plc_daemon crond
51         check
52
53         result "$MESSAGE"       
54         ;;
55
56     stop)
57         MESSAGE=$"Stopping crond"
58         dialog "$MESSAGE"
59
60         killproc plc_crond
61         check
62
63         result "$MESSAGE"       
64         ;;
65 esac
66
67 exit $ERRORS