Cron Jobs Misbehaving in CDOT 8.2.X


Some cron jobs that don’t behave as expected!


1) ::> cron create -name Nightly_Tue-Sun@01 -minute 0 -hour 1 -dayOfWeek Tue-Sun

This was meant to trigger at 1am everyday Tuesday to Sunday (Tue, Wed, Thu, Fri, Sat, Sun), but in fact it does Sun-Tue, so only triggered at 1am every Sunday, Monday, and Tuesday!

2) ::> cron create -name Weekly_Mon_8th-31st -minute 0 -hour 1 -dayOfWeek Mon -Day 8-31

This was meant to trigger on a Monday which exists between the dates of the 8th to the 31st, but it was actually triggering on every day that's a Monday, and every day between 8 and 31!

3) ::> cron create -name Monthly_Mon_1st-7th -minute 0 -hour 1 -dayOfWeek Mon -Day 1-7

This was meant to trigger on a Monday which exists between the dates of the 1st to the 7th, but it was actually triggering on every Monday, and every day between 1st and 7th!


For reference, the original cron schedules and snapshot policy they were intended for, how they should have been created in the first place and how they were fixed, are below.

########################################################
# Original Cron Schedules and Snapshot Policy Creation #
########################################################

cron create -name Hourly_Not@01 -minute 0 -hour 0,2-23
cron create -name Nightly_Tue-Sun@01 -minute 0 -hour 1 -dayOfWeek Tue-Sun
cron create -name Weekly_Mon_8th-31st -minute 0 -hour 1 -dayOfWeek Mon -Day 8-31
cron create -name Monthly_Mon_1st-7th -minute 0 -hour 1 -dayOfWeek Mon -Day 1-7

snapshot policy create -policy SP_1M_2W_13N_23H -schedule1 Hourly_Not@01 -count1 23 -snapmirror-label1 hourly -prefix1 hourly -enabled true
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Nightly_Tue-Sun@01 -count 13 -snapmirror-label nightly -prefix nightly
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Weekly_Mon_8th-31st -count 2 -snapmirror-label weekly -prefix weekly
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Monthly_Mon_1st-7th -count 1 -snapmirror-label monthly -prefix monthly

######################################################
# How it should have been created in the first place #
######################################################

cron create -name Hourly_Not@01 -minute 0 -hour 0,2-23
cron create -name Nightly_Tue-Sun@01 -minute 0 -hour 1 -dayOfWeek Sun,Tue-Sat
cron create -name Weekly_Mon@01 -minute 0 -hour 1 -dayOfWeek Mon
cron create -name Monthly_01@00 -minute 1 -hour 0 -Day 1

snapshot policy create -policy SP_1M_2W_13N_23H -schedule1 Hourly_Not@01 -count1 23 -snapmirror-label1 hourly -prefix1 hourly -enabled true
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Nightly_Tue-Sun@01 -count 13 -snapmirror-label nightly -prefix nightly
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Weekly_Mon@01 -count 2 -snapmirror-label weekly -prefix weekly
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Monthly_01@00  -count  1 -snapmirror-label  monthly -prefix monthly

###########################
# Correcting the mistakes #
###########################

cron modify -name Nightly_Tue-Sun@01 -dayOfWeek Sun,Tue-Sat
cron create -name Weekly_Mon@01 -minute 0 -hour 1 -dayOfWeek Mon
cron create -name Monthly_01@00 -minute 1 -hour 0 -Day 1

snapshot policy remove-schedule -policy SP_1M_2W_13N_23H -schedule Weekly_Mon_8th-31st
snapshot policy remove-schedule -policy SP_1M_2W_13N_23H -schedule Monthly_Mon_1st-7th
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Weekly_Mon@01 -count 2  -snapmirror-label weekly  -prefix weekly
snapshot policy add-schedule -policy SP_1M_2W_13N_23H -schedule Monthly_01@00 -count 1  -snapmirror-label monthly -prefix monthly

cron delete Weekly_Mon_8th-31st
cron delete Monthly_Mon_1st-7th

Comments