How to setup cron job to run every 5 days?
0 0 */5 * * midnight every 5 days.
See this, similar question just asked for every 3 days. Cron job every three days
Bear with me, this is my first time posting an answer... let me know if anything I put is unclear.
I don't think you have what you need with:
0 0 */5 * * ## <<< WARNING!!! CAUSES UNEVEN INTERVALS AT END OF MONTH!!
Unfortunately, the */5 is setting the interval based on day of the month. See: explanation here. At the end of the month there is recurring issue guaranteed.
1st at 2019-01-01 00:00:00
then at 2019-01-06 00:00:00 << 5 days, etc. OK
then at 2019-01-11 00:00:00
...
then at 2019-01-26 00:00:00
then at 2019-01-31 00:00:00
then at 2019-02-01 00:00:00 << 1 day WRONG
then at 2019-02-06 00:00:00
...
then at 2019-02-26 00:00:00
then at 2019-03-01 00:00:00 << 3 days WRONG
According to this article, you need to add some modulo math to the command being executed to get a TRUE "every N days". For example:
0 0 * * * bash -c '(( $(date +\%s) / 86400 \% 5 == 0 )) && runmyjob.sh
In this example, the job will be checked daily at 12:00 AM, but will only execute when the number of days since 01-01-1970 modulo 5 is 0.
If you want it to be every 5 days from a specific date, use the following format:
0 0 * * * bash -c '(( $(date +\%s -d "2019-01-01") / 86400 \% 5 == 0 )) && runmyjob.sh