On Thu, May 3, 2018 at 10:44 AM, Alex Beamish via talk <[email protected]>
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
---
Talk Mailing List
[email protected]
https://gtalug.org/mailman/listinfo/talk

Reply via email to