Got questions? Go ahead: Ask me anything!
I have a cron job that runs every hour. Within that script I need to test for specific times. For example, if today is the 27th and it is 4 AM, I need to run another script.
Of course you could do this with separate cron jobs, but if you want to maintain one script that you'll run hourly, it would look something like this:
if [ $DOM -eq 27 ]
if [ $HR -eq 05 ]
Most of us wouldn't write it like that, though. We'd do:
if [ $DOM -eq 27 -a $HR -eq 04 ]
Watch your spacing - can't do "if [$HR -eq 05 ]" (no space after "[").
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Anthony Lawrence
Find me on Google+
© 2015-08-06 Anthony Lawrence