[GTALUG] Crontab versioning
Clifford Ilkay
cilkay at gmail.com
Thu May 3 16:34:20 EDT 2018
On Thu, May 3, 2018 at 10:44 AM, Alex Beamish via talk <talk at gtalug.org>
wrote:
> I'm developing scripts that get run by crontab, so I'm in there making
> updates fairly regularly. I would love to be able to document the changes,
> so I'm wondering if there a usual and customary technique to version
> crontabs?
>
> Ideally there would be some sort of hook around 'crontab -e', but failing
> that, I'd have the output of 'crontab -l' (run regularly by cron?) go to a
> versioned file. Plan B sounds a bit hokey to me.
>
I do this using git and SaltStack. Here is my Salt state for managing the
root crontab.
cron:
service.running:
- name: cron
- enable: True
root-crontab:
file.managed:
- name: /root/root-crontab
- source: salt://cronjobs/root-crontab
- template: jinja
cmd.run:
- name: cd /root; /usr/bin/crontab -r; /usr/bin/crontab root-crontab
The file called root-crontab is under revision control. One of the things
that is in root-crontab is first, updating the Salt states and second,
invoking them. That could include updating the root-crontab. There are
other ways of doing this in SaltStack.
Regards,
Clifford Ilkay
+1 647-778-8696
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gtalug.org/pipermail/talk/attachments/20180503/a0c90d1f/attachment.html>
More information about the talk
mailing list