I will continue Keith Thompson's answer:
His solution works fine every 5 minutes, but will not work, say, every 13 minutes; if we use $minutes % 13 , we get this schedule:
5:13 5:26 5:30 5:52 6:00 because 0%13 is 0 6:13 ...
I am sure you noticed this problem. We can achieve any frequency by counting minutes (hours, days or weeks) with Epoch :
#!/bin/bash minutesSinceEpoch=$(($(date +'%s / 60'))) if [[ $(($minutesSinceEpoch % 13)) -eq 0 ]]; then php [...] fi
date(1) returns the current date, we will format it as seconds with Epoch ( %s ), and then do the basic mathematical data:
# .---------------------- bash command substitution
And you can use this approach with the hourly, daily or monthly cron job on OpenShift:
#!/bin/bash
Note that I used the -ne operator (not equal) to exit the script instead of using the -eq (equal) operator to transfer the script to the IF construct; Itβs convenient for me.
And don't forget to use the correct .openshift/cron/{minutely,hourly,daily,weekly,monthly}/ folder for your frequency.
stefanmaric
source share