From: Robert Klemme Date: 2004-10-11T17:29:38+09:00 Subject: Re: Task scheduling using Ruby? "nkb" schrieb im Newsbeitrag news:416A3DFF.9010804@pacific.net.sg... > Hi. > I would like to schedule a task (e.g check if a file exists or if the > date of the files in a diretory are newer than yesterday, etc.) on Linux > using Ruby. Can this be done, if so how? I supposed I would run the > script as root background? Thanks for any pointer!! Of course you can do it with ruby. However on a *nix box however the usual approach is to use cron. There might be reasons why you don't want to use cron. If I'd do it in Ruby I probably had a class ScheduledEvent with methods #next_execution and #execute. I'd then keep a priority queue of ScheduledEvents sorted by #next_execution. Pick the first, calculate the difference in seconds from now till then and sleep for that time. Of course, you'll have to take additional actions if the queue contents should be able to change at any time (i.e. new events are defined or old events are deleted). Kind regards robert