[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Schedule Ruby Code!

bashar.ayyash@gmail.com

11/8/2007 6:31:00 AM

Hello,

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.


Your help is really appreciated,
Regards,

3 Answers

Mohit Sindhwani

11/8/2007 7:11:00 AM

0

bashar.ayyash@gmail.com wrote:
> Hello,
>
> 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.
>
>
> Your help is really appreciated,
> Regards,
>
>
If you're on Linux/ Unix, use cron. If you're on Windows, use PyCron to
schedule your code to run at whatever interval you like.

Cheers,
Mohit.
11/8/2007 | 3:10 PM.

>
>
>



John Mettraux

11/8/2007 7:52:00 AM

0

On Nov 8, 2007 3:38 PM, bashar.ayyash@gmail.com <bashar.ayyash@gmail.com> wrote:
> Hello,
>
> 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.

Hi Bashar,

To list the content of a folder, take a look at the Dir class
(http://corelib.rubyonrails.org/classe...), if you need
something a bit more 'recursive', look at Find
(http://stdlib.rubyonrails.org/libdoc/find/rdoc/...).

To generate the XML file, have a look at REXML,
http://www.germane-software.com/software/rexml/docs/tut...

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 :

---8<---

require 'rubygems'
require 'openwfe/util/scheduler'
# sudo gem install openwferu-scheduler

s = OpenWFE::Scheduler.new
s.start

s.schedule("0,30 * * * *") do
# twice per hour, at minute 0 and at minute 30

generate_xml_file()
# your method
end

--->8---

more info at http://openwferu.rubyforge.org/sche...

If your script is just a sysadmin helper, it's probably wiser to stick
with the cron utility of your platform.


Best regards,

--
John Mettraux -///- http://jmettraux.o...

bashar.ayyash@gmail.com

11/8/2007 10:40:00 AM

0

On Nov 8, 9:52 am, John Mettraux <jmettr...@openwfe.org> wrote:
> On Nov 8, 2007 3:38 PM,bashar.ayy...@gmail.com <bashar.ayy...@gmail.com> wrote:
>
> > Hello,
>
> > 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.
>
> HiBashar,
>
> To list the content of a folder, take a look at the Dir class
> (http://corelib.rubyonrails.org/classe...), if you need
> something a bit more 'recursive', look at Find
> (http://stdlib.rubyonrails.org/libdoc/find/rdoc/...).
>
> To generate the XML file, have a look at REXML,http://www.germane-software.com/software/rexml/docs/tut...
>
> 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 :
>
> ---8<---
>
> require 'rubygems'
> require 'openwfe/util/scheduler'
> # sudo gem install openwferu-scheduler
>
> s = OpenWFE::Scheduler.new
> s.start
>
> s.schedule("0,30 * * * *") do
> # twice per hour, at minute 0 and at minute 30
>
> generate_xml_file()
> # your method
> end
>
> --->8---
>
> more info athttp://openwferu.rubyforge.org/sche...
>
> If your script is just a sysadmin helper, it's probably wiser to stick
> with the cron utility of your platform.
>
> Best regards,
>
> --
> John Mettraux -///- http://jmettraux.o...

Thank you very much John for your help and giving me great tips...!