On Nov 8, 2007 3:38 PM, [email protected]
[email protected] wrote:
I want to build a ruby script that list contents of a folder and put
this list in a generated XML files (actually two files), and I want to
schedule this script to run every 30 minutes.
Pls. if you could tell me where I should start and how to make this
script run every 30 minutes, I’m new to the language I liked it and I
want to learn it more.
To list the content of a folder, take a look at the Dir class
(http://corelib.rubyonrails.org/classes/Dir.html), if you need
something a bit more ‘recursive’, look at Find
To generate the XML file, have a look at REXML,
Now for the scheduling, as Mohit said, let the “cron” system of your
platform run your job.
If you want to stay Ruby, you can use the OpenWFEru scheduler and
write something like :
# sudo gem install openwferu-scheduler
s = OpenWFE::Scheduler.new
s.schedule(“0,30 * * * *”) do
# twice per hour, at minute 0 and at minute 30
# your method
more info at http://openwferu.rubyforge.org/scheduler.html
If your script is just a sysadmin helper, it’s probably wiser to stick
with the cron utility of your platform.