Currently I'm using /usr/bin/ifNotNearMidnight as:
#!/bin/bash
t=$(date +\%H\%M)
if [[ "$t" > 2350 ]] || [[ "$t" < 0010 ]]
then
exit 1
fi
And then in cron:
* * * * * ifNotNearMidnight && ( cd /blah/ ; doTheThing )
Currently I'm using /usr/bin/ifNotNearMidnight as:
#!/bin/bash
t=$(date +\%H\%M)
if [[ "$t" > 2350 ]] || [[ "$t" < 0010 ]]
then
exit 1
fi
And then in cron:
* * * * * ifNotNearMidnight && ( cd /blah/ ; doTheThing )
Sorta. The "<" does string comparison rather than integer comparison (which would use -lt and have octal issues…good catch on that possibility), but since the date(1) command produces 0-padded output like "0009", it should be fine:
$ [[ 9 < 0010 ]] && echo yep || echo nope
nope
$ [[ 0009 < 0010 ]] && echo yep || echo nope
yep
$ [[ 9 -lt 0010 ]] && echo yep || echo nope
nope
$ [[ 9 -lt 10 ]] && echo yep || echo nope
yep