<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 4, 2018 at 8:11 AM, Jamon Camisso via talk <span dir="ltr"><<a href="mailto:talk@gtalug.org" target="_blank">talk@gtalug.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2018-05-03 10:44 AM, Alex Beamish via talk wrote:<br>
> I'm developing scripts that get run by crontab, so I'm in there making<br>
> updates fairly regularly. I would love to be able to document the changes,<br>
> so I'm wondering if there a usual and customary technique to version<br>
> crontabs?<br>
<br>
</span>What are you changing in crontabs so much that you need versioning?<br></blockquote><div><br></div><div>I'm developing EDI scripts, and as development progresses, some of the older scripts are being replaced by newer scripts. On occasion, there are times when I need to disable a crontab job while I solve an issue.</div><div><br></div><div>Having version control would be a great back-stop, and would also be useful from a historical point of view. (Why did I disable that job last Thursday? Where did the such and such script go?)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Shouldn't all the logic be in your scripts? Maybe I'm missing something,<br>
but it seems like needless complication to me.<br></blockquote><div><br></div><div>What to do and how to do it is in the scripts. How often to do it is in the crontab.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
> Ideally there would be some sort of hook around 'crontab -e', but failing<br>
> that, I'd have the output of 'crontab -l' (run regularly by cron?) go to a<br>
> versioned file. Plan B sounds a bit hokey to me.<br>
</span>If you do need to version things, you can just chuck a git repo under<br>
/var/spool/cron/crontabs and ignore any files there you don't want tracked.<br></blockquote><div><br></div><div>Under my system, that directory is owned by root, and I prefer not to version anything as root; the code I'm developing is application code, not system code.</div><div><br></div><div>The solution I'm leaning towards is to have a shell script for updating the crontab that would do something like</div><div>1. pushd $local_crontab_directory</div><div>2. crontab -e</div><div>3. crontab -l >crontab.$username</div><div>4. git diff <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">crontab.$username</span></div><div><br></div><div>If there were changes revealed by the 'git diff', and if I felt they were significant, I could do a git commit, followed by a popd.</div><div><br></div><div>Thanks for your questions -- they helped me clarify my understanding of the problem and a possible solution.</div><div><br></div></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="2">Alex Beamish</font></div><div dir="ltr"><font size="2"><br></font></div><div dir="ltr"><font size="2">Software Developer / <span style="background-color:rgb(246,246,246);color:rgb(51,51,51);font-family:helvetica,freesans,"liberation sans",helmet,arial,sans-serif"><a href="https://ca.linkedin.com/in/alex-beamish-5111ba3" target="_blank">https://ca.linkedin.com/in/alex-beamish-5111ba3</a></span><br></font></div><div><font size="2">Speaker Wrangler, Toronto Perlmongers / <a href="http://to.pm.org/" target="_blank">http://to.pm.org/</a></font></div><div dir="ltr"><font size="2">Baritone, Board Member, Toronto Northern Lights, 2013 Champions / <a href="http://www.northernlightschorus.com" target="_blank">www.northernlightschorus.com</a></font></div><div dir="ltr"><font size="2">Certified Contest Administrator, Barbershop Harmony Society / <a href="http://www.barbershop.org" target="_blank">www.barbershop.org</a></font></div><div><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div></div>