<div dir="ltr">Keep in mind, if you just want to view the crontab without editing it. <div><br></div><div># crontab -l<br></div><div><br></div><div>I feel it is safer to use functionality to view for viewing and functionality for editing to edit. Ex. cat or less to view a file and vim to edit.<div>
<div><br></div><div>Will Weaver<br></div></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 18, 2013 at 1:43 PM, Christopher Browne <span dir="ltr"><<a href="mailto:cbbrowne@gmail.com" target="_blank">cbbrowne-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Fri, Oct 18, 2013 at 1:32 PM, Scott Sullivan <<a href="mailto:scott-lxSQFCZeNF4@public.gmane.org">scott-lxSQFCZeNF4@public.gmane.org</a>> wrote:<br>

> So, I just discovered crontab -r.<br>
<br>
</div>Eek!!!  I didn't know that existed.<br>
<br>
One of my Standard Patterns in cfengine+Git is to run the following script...<br>
<br>
---- snip bit of cfengine code.. ----<br>
shellcommands:<br>
    "$(GITHOME)/Scripts/savecrons.sh > /dev/null 2> /dev/null"<br>
---- snip bit of cfengine code.. ----<br>
<br>
Voila "savecrons.sh"...<br>
<br>
#!/bin/bash<br>
CRONHOME=${HOME}/GitHome/InitFiles/cron<br>
pushd ${CRONHOME}<br>
CRONTABOUTPUT=`whoami`.`hostname`<br>
echo "Saving crontab to ${CRONTABOUTPUT}"<br>
crontab -l > ${CRONTABOUTPUT}<br>
git add ${CRONTABOUTPUT}<br>
git commit -m "Saving crontab for user ${USERNAME} on host ${HOST}"<br>
${CRONTABOUTPUT}<br>
popd<br>
<div class="im"><br>
> Small things like this can make or break your day, and stresses that 'RAID'<br>
> is not a back-up, and the importance of having back-ups! Most of you know<br>
> this, but for those have forgotten or are new, just remember your a<br>
> keystroke away from doom.<br>
<br>
</div>Back when I was DBA'ing in production, and didn't have Git in<br>
production areas, I had a similar script to "savecrons.sh" which<br>
would...<br>
 --> Dump current crontab into a fixed place...<br>
 --> See if that's the same as it was last time I ran the script<br>
 --> If not, then take one of the copies and give it a name based on<br>
today's timestamp<br>
<br>
That would give a history of whenever the crontab got messed with.<br>
Not as good as checking it into an SCM, but a *great* deal better than<br>
nothing...<br>
<br>
Having some reasonable sort of backup makes "crontab -r" a wildly less<br>
scary thing! :-)<br>
<div class="HOEnZb"><div class="h5">--<br>
The Toronto Linux Users Group.      Meetings: <a href="http://gtalug.org/" target="_blank">http://gtalug.org/</a><br>
TLUG requests: Linux topics, No HTML, wrap text below 80 columns<br>
How to UNSUBSCRIBE: <a href="http://gtalug.org/wiki/Mailing_lists" target="_blank">http://gtalug.org/wiki/Mailing_lists</a><br>
</div></div></blockquote></div><br></div>