3 ms·
Interestingly, and on further consideration, using date with %w (as in the example I provided) suffers from the same problem, lol! Creating a file as you did sh
by dinom 5y ago
Interestingly, and on further consideration, using date with %w (as in the example I provided) suffers from the same problem, lol! Creating a file as you did should work nicely. Or a fair bit more arithmetic could be done using date's %s, not my cup of tea though.
As mentioned, the next problem appears when the job takes longer than two days, which requires using flock. I often prefer to use mkdir instead of flock, provided your mkdir is atomic and POSIX compliant... which is usually the case AFAIK. E.G. mkdir a-lock-dir || exit;... rmdir a-lock-dir
Ultimately I don't have too many complaints about cron. But, like anything, it has it's own quirks. Indeed a handy article.
- soneil 5y agoyeah, calendar manipulation is trickier than it looks. If you use day-of-week, you have an odd number of days. If you use day of month, many months have an odd number. If you use day of year (%j), most years have an odd number. There's many such examples - every 1, 2, 3, 4, 6 hours works - but every 5 hours doesn't. But every 2 days and every 14 days are requirements I've met IRL.