cron
cron copied to clipboard
What is the right way to store a cron in a database
I will be moving to production and I need to save my cron in a database. It looks like it can be saved as gob. I am afraid that the transactions will overlap with multiple readers and writers. What is the best way to do this?
Can I piggy-back on this by asking the same question of file storage?
My current code will just literally store the contents of cron.Entries() in a gob, which is then buffered and written to a file. Fine. The question then becomes how can I 'inject' that joblist back into cron, I'm thinking along the lines of using cron.Parser but am a little unsure if that's the best way to proceed?
@lowlevelcodehustler, Turns out you are right. Cron needs to have exported fields to be gob encoded.
This also answers a lot of my questions. Should I run one cron for all entries? Should I run one cron per entry?
It looks like you need to save/persist the spec and the function(AddFunc) or spec and the job(AddJob) details to be run in a file or database. Cron only cares about what is running now. So if you restart the cron server, all these jobs or funcs need to be restarted with any cron. Am I right?