A few years ago I wrote a simple perl script that looks to a Database and processes any jobs. It runs in an instance of screen that I keep running on a server. The script is a "while (1){...;sleep(30);}" type script. I wanted the script to run more frequently than every minute and I wanted to be able to keep track of its progress. For some reason I didn't want to write output to a log file or check the DB to ensure jobs had run as expected.
I'd really like to move away from that screen'ed script and move it to something that starts when the server reboots / and is kept running should anything go wrong with it (shockingly nothing has killed it to date). My mentor at work recently showed us Ubic in a presentation for doing just this sort of thing. So I've spent the morning studying Ubic, along with some of the blog entries for creating a simple Ubic service.
The worker script:
The service description:
Some sample output in the log file:
As you can see, its a very simple setup to replicate multiple worker threads that take an indeterminate amount of time to complete their jobs.
My next task is to actually move my original script out of screen and into Ubic for better resiliency and tracking. The other task I have ahead of me is monitoring Ubic to ensure my scripts remain running. Remember to "Trust, but verify"!