Thursday, November 14, 2013

Motivation via /etc/motd

It's about the time of year when everything and everyone bugs me. To amplify this typical November feeling, the company I work for was purchased a couple of years back, and are really ramping up the outsourcing (sorry....cost reduction initiative). So things generally suck anyhow.

To combat the feelings of despair, and total lack of motivation..I thought it would be a nice idea to remind myself how many days until I go on Christmas break. My main Ops server doesn't have a lot of GNU packages (like gnu date) so I'll use perl.



Script looks like this:


#!/usr/bin/perl
use strict;
use warnings;
use Time::Local;
use POSIX;

my @today = localtime();
my $time = timelocal(@today);

my @holiday = (0, 30, 15, 23, 11, 2013);
my $holidayTime = timelocal(@holiday);

print "\nDays Until Holidays = " . floor((((($holidayTime - $time) / 60) / 60) / 24)) . "\n\n";

exit 0;


Crontab looks like this:

# Update MOTD

0 1 * * * /usr/bin/perl /usr/local/scripts/motd/motd.pl > /etc/motd 2>&1


Output looks like this: