Permalink
Browse files

Update cron functionality for snapshots, allow us to specify a specif…

…ic hour to

run at when doing daily snapshots
  • Loading branch information...
1 parent a4ac142 commit f6159587202280e77bcdd366ccea8e99df178a5e @kmoore134 kmoore134 committed Aug 6, 2013
@@ -104,7 +104,7 @@ enable_cron()
fi
case $2 in
- daily) cLine="0 01 * * *" ;;
+ daily) cLine="0 $4 * * *" ;;
hourly) cLine="0 * * * *" ;;
30min) cLine="0,30 * * * *" ;;
10min) cLine="*/10 * * * *" ;;
@@ -21,6 +21,15 @@ fi
if [ "$ACTION" = "start" ] ; then
TIME="${3}"
+
+ # See if the user is running daily with a hour specified
+ echo $TIME | grep -q "daily"
+ if [ $? -eq 0 ] ; then
+ hour="`echo $TIME | cut -d '@' -f 2`"
+ if [ -z "$hour" ] ; then hour="22" ; fi
+ TIME="daily"
+ fi
+
COUNT="${4}"
case $TIME in
daily|hourly|30min|10min|5min) ;;
@@ -30,8 +39,8 @@ if [ "$ACTION" = "start" ] ; then
echo "ERROR: Invalid count specified!" ; exit 5
fi
- enable_cron "$DATASET" "$TIME" "$COUNT"
- echo "Snapshot frequency set: $TIME"
+ enable_cron "$DATASET" "$TIME" "$COUNT" "$hour"
+ echo "Snapshot frequency set: $TIME @ $hour"
echo "Snapshot # to keep set: $COUNT"
exit 0
fi
@@ -18,7 +18,7 @@ do
min=`grep "${PROGDIR}/backend/runsnap.sh" /etc/crontab | awk '{print $1}'`
hour=`grep "${PROGDIR}/backend/runsnap.sh" /etc/crontab | awk '{print $2}'`
time="Min: $min Hour: $hour";
- if [ "$min" = "0" -a "$hour" = "01" ] ; then time="daily" ; fi
+ if [ "$min" = "0" -a "$hour" != '*' ] ; then time="daily@$hour" ; fi
if [ "$min" = "0" -a "$hour" = '*' ] ; then time="hourly" ; fi
if [ "$min" = "0,30" ] ; then time="30min" ; fi
if [ "$min" = '*/10' ] ; then time="10min" ; fi
@@ -207,12 +207,13 @@ Usage:
# lpreserver cronsnap <dataset> <action> <frequency> <numToKeep>
action = start / stop
- frequency = daily / hourly / 30min / 10min / 5min
+ frequency = daily@XX / hourly / 30min / 10min / 5min
+ ^^ Hour to execute
numToKeep = Number of snapshots to keep total
Example:
- lpreserver cronsnap tank1/usr/home/kris start daily 10
+ lpreserver cronsnap tank1/usr/home/kris start daily@22 10
or

0 comments on commit f615958

Please sign in to comment.