Better Living Through Thinking

Tell Even from Odd Days

Tue, 17 Apr 2007

Here's a small utility to tell even from odd days (useful in some crontabs):

#!/usr/bin/perl -s
exit(((localtime)[3]+($odd||0)) % 2);

Save this to /usr/local/sbin/evenday, chmod 755 /usr/local/sbin/evenday and chown root:wheel /usr/local/sbin/evenday

Now in your crons you can do this:

## on the even Tuesdays...
* * * * 2 /usr/local/sbin/evenday && /run/some/even_backup.sh

## on odd-numbered Tuesdays...
* * * * 2 /usr/local/sbin/evenday -odd && /run/some/odd_backup.sh
[ category: /sysadmin | link: evenday ]

Audio Broadcast

(standby)

Moon Status

Phase: 64.16%
Illuminated: 81.47%
Age (days): 18.95
moon phase 0.641640415053247 Fri Jul 30 11:14:05 MDT 2010