Great post. And if you want some control support for your cronjobs perl App::Cronjob[1] can provide features such has exclusive locking, so a job won't run if the previous run is still going, or provide a timeout, and some options for sending mail on success or failure
Also check out the 'chronic' command from moreutils. No more dev nulls.
Does anyone maintain a programmatically accessible list of holidays for their company? Similar to the HOLIDAYS.txt in the article, but it would allow for things like “don’t run this the day before or during a company holiday.”
I work at a company with different holidays in certain countries, which would complicate things, and require something more structured than a list of dates. But having that accessible could be useful.
Has anyone tackled that, or come across a solution?
At our company we have enough systems reliant on holiday dates that we have a Holiday system that emits events when there are changes.
This happens surprisingly often, given that religious dates change and there are holidays/closures for storms in some regions.
Ruby has https://github.com/bokmann/business_time but when I looked at it, custom code was needed to calculate holidays that were offset because they are on the weekend.
This is great! I'm sure like a lot of programmers, I had been fulfilling the requirement for similar conditional logic by having a simple recurring cron job run other code or database queries with the conditional logic that this post demonstrates can be done directly in cron.
Cool. Had no idea you could run commands inside a CRON expression.
Running a command is the main idea of cron. In this case, the author runs composite commands like:
test && action
Where 'test' is another shell command that returns 0 or 1. This is not a special cron syntax, it's just the inherent capability of the Unix shell.
In any case, this whole approach is very clever and shows the beauty of The Unix Way.
Great post. And if you want some control support for your cronjobs perl App::Cronjob[1] can provide features such has exclusive locking, so a job won't run if the previous run is still going, or provide a timeout, and some options for sending mail on success or failure
[1]https://metacpan.org/pod/App::Cronjob https://metacpan.org/dist/App-Cronjob/view/bin/cronjob
Also check out the 'chronic' command from moreutils. No more dev nulls.
Does anyone maintain a programmatically accessible list of holidays for their company? Similar to the HOLIDAYS.txt in the article, but it would allow for things like “don’t run this the day before or during a company holiday.”
I work at a company with different holidays in certain countries, which would complicate things, and require something more structured than a list of dates. But having that accessible could be useful.
Has anyone tackled that, or come across a solution?
At our company we have enough systems reliant on holiday dates that we have a Holiday system that emits events when there are changes.
This happens surprisingly often, given that religious dates change and there are holidays/closures for storms in some regions.
Ruby has https://github.com/bokmann/business_time but when I looked at it, custom code was needed to calculate holidays that were offset because they are on the weekend.
This is great! I'm sure like a lot of programmers, I had been fulfilling the requirement for similar conditional logic by having a simple recurring cron job run other code or database queries with the conditional logic that this post demonstrates can be done directly in cron.
Cool. Had no idea you could run commands inside a CRON expression.
Running a command is the main idea of cron. In this case, the author runs composite commands like:
Where 'test' is another shell command that returns 0 or 1. This is not a special cron syntax, it's just the inherent capability of the Unix shell.In any case, this whole approach is very clever and shows the beauty of The Unix Way.