CRON
If you have ever worked on a UNIX/UNIX-like OS, Im’ pretty sure how quick you’ll get to admire those amazing and powerful OS features and command lines. And if you also work on Windows and do a lot of automation, I’m sure you’ll love it that sometimes you wish you had that feature in Windows. One of my favorite is CRON, the time-based job scheduler in Unix-like computer operating systems. Yes, I know we have the good old Task Scheduler in Windows, but I really like how you can configure a complex scheduled job in one line of text with CRON.
It maybe a little over the top to create something like this on Windows, considering that Task Scheduler will be able to achieve the same goal. But I got this really strange error in one of my scheduled job that kept me head scratching for days. The job will just show in running state, it will never run and the “end task” option is greyed out so the only fix is to restart the scheduler service. I normally try to investigate the problem and find the root cause but this time I had enough that it made me decide to create the scheduler I want – one with a CRON-like syntax. And luckily, I dont have to. QUARTZ.NET, a .NET open source library already has this functionality. So I just need to build my program on top of it.
With the help of QUARTZ, I created a windows service that reads the configuration files for scheduled jobs. The time schedule uses a CRON like syntax.
Below is a section in the AppConfig where you can schedule the jobs:
<section name="jobs" type="Assyst.JobProcessor.Scheduler.JobConfigurationHandler, Assyst.JobProcessor.Scheduler"/> <jobs> <job name="MyJob" type="MyProject.MyJobClass, MyProject" schedule="30 0/1 * * * ?" /> </jobs>
JobConfigurationHandler is an implementation of IConfigurationSectionHandler interface, which reads the AppConfig for the scheduled jobs. And MyJobClass is a class which derives from an abstract class, AssystJobBase, which is simply a template class to easily create job class. This abstract class implements the IAssystJob Interface which is the only requirement for a class to be configured as scheduled job. The schedule attribute obviously is where you put your CRON-like syntax for scheduling the job.
I have temporarily uploaded the project here but it will soon be on my GITHUB repository.
Monitor UNIX Disk Space
A simple script for monitoring UNIX Disk space usage that sends an email alert if % usage is above the alert level.
THRESHOLD=90
RECIPIENTS="admin@company.com.qa"
DISK_ALERT_LOG="/tmp/diskalert.log"
DISK_ALERT_MAIL="/tmp/diskalert.mail"
touch ${DISK_ALERT_LOG}
df -h | awk '{if(NR>1){print$6" "$5}}' | while read output
do
USAGE=`echo $output | sed 's/\%//' | awk '{print$2}'`
MOUNT=`echo $output | awk '{print$1}'`
if [ ${USAGE} -gt ${THRESHOLD} ];
then
echo "${MOUNT} = ${USAGE}%" >> ${DISK_ALERT_LOG}
fi
done
cat ${DISK_ALERT_LOG}
if [ -s ${DISK_ALERT_LOG} ];
then
echo "To: ${RECIPIENTS}" > ${DISK_ALERT_MAIL}
echo "From: ${HOSTNAME}" >> ${DISK_ALERT_MAIL}
echo "Subject: Disk space alert on ${HOSTNAME}" >> ${DISK_ALERT_MAIL}
echo >> ${DISK_ALERT_MAIL}
cat ${DISK_ALERT_LOG} >> ${DISK_ALERT_MAIL}
cat ${DISK_ALERT_MAIL} | /bin/mail ${RECIPIENTS}
fi
rm ${DISK_ALERT_LOG}
The Git Effect
Many developers, including those notable persons over the .NET community have been moving their open source projects to Git and Github lately. (Git is a free and open source, distributed version control system. And Github is an online project hosting that uses Git as its revision control system.)
Rob Conery’s SubSonic is now on Github. As of September 14, 2009, Sharp Architecture’s source repository is now being hosted at http://Github.com/codai/Sharp-Architecture. Oren Eini (aka Ayende Rahien) has recently moved to Git, not only he is a famous NHibernate developer and creator of RhinoMocks, but interestingly a long time user of SubVersion and a developer of SvnBridge (SvnBridge allows you to use TortoiseSVN and other Subversion clients with Team Foundation Server).
I’ve been using SubVersion for my hobby projects and I consider it as an excellent version control system. Far better than VSS - which unfortunately my company is still using.
But is there any compelling reason to try Git or even completely switch from SubVersion (or any other version control system) and not just because it’s what the “Kool Kids” are using? TBH, I really don’t know. But there is one thing that I am sure of - the recent noise about Git is something a developer cannot ignore (at least for the curious ones). And Aaron Jensen is right, maybe I heard it enough that I want to give it a try and see why they think it’s so great.
And sure enough I did. I have setup a GitHub account to host my hobby projects. Currently I have only my “splotter-common” project uploaded. As of now, the project contains the common code base of my own implementation (inspired by Oren’s RhinoCommons) of Data Persistence, Repository and Unit of Work pattern using NHibernate, Linq for NHibernate and Linq to SQL.
Learning Photography 101
After struggling with our old, broken shutter button, 7 megapixel Sony compact digital camera, we decided to buy the Canon SX10 IS. A point and shoot superzoom camera with a whooping 20x optical zoom. We chose this camera because it has full sets of manual controls that can help me learn the basics of digital photography without spending for a more complex, bigger and expensive DSLRs.
I did not expect learning photography would be this fun and interesting. Somehow, it has already changed the way we capture those special moments. Applying the Rules of Thirds, playing with the Depth of Field to shoot Bokeh, shooting a moving subject by Panning.
But then recently, I just found out, that sometime back I was caught by an extremely fast Shutter Speed. But sadly, it wasn’t from my own camera…

They say digital photography is expensive. Well, I guess I just found out. The picture cost me 500 Qatari Riyals, equivalent to about 137 US $ and about 6,686 Philippine Pesos.

Splotter's Code.

Recent Comments