A keystroke away from Doom.

Christopher Browne cbbrowne-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Fri Oct 18 17:43:27 UTC 2013


On Fri, Oct 18, 2013 at 1:32 PM, Scott Sullivan <scott-lxSQFCZeNF4 at public.gmane.org> wrote:
> So, I just discovered crontab -r.

Eek!!!  I didn't know that existed.

One of my Standard Patterns in cfengine+Git is to run the following script...

---- snip bit of cfengine code.. ----
shellcommands:
    "$(GITHOME)/Scripts/savecrons.sh > /dev/null 2> /dev/null"
---- snip bit of cfengine code.. ----

Voila "savecrons.sh"...

#!/bin/bash
CRONHOME=${HOME}/GitHome/InitFiles/cron
pushd ${CRONHOME}
CRONTABOUTPUT=`whoami`.`hostname`
echo "Saving crontab to ${CRONTABOUTPUT}"
crontab -l > ${CRONTABOUTPUT}
git add ${CRONTABOUTPUT}
git commit -m "Saving crontab for user ${USERNAME} on host ${HOST}"
${CRONTABOUTPUT}
popd

> Small things like this can make or break your day, and stresses that 'RAID'
> is not a back-up, and the importance of having back-ups! Most of you know
> this, but for those have forgotten or are new, just remember your a
> keystroke away from doom.

Back when I was DBA'ing in production, and didn't have Git in
production areas, I had a similar script to "savecrons.sh" which
would...
 --> Dump current crontab into a fixed place...
 --> See if that's the same as it was last time I ran the script
 --> If not, then take one of the copies and give it a name based on
today's timestamp

That would give a history of whenever the crontab got messed with.
Not as good as checking it into an SCM, but a *great* deal better than
nothing...

Having some reasonable sort of backup makes "crontab -r" a wildly less
scary thing! :-)
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list