From: Logan Capaldo Date: 2004-11-12T04:56:49+09:00 Subject: Re: Writing a looping, low-configuration script in Ruby Well if you don't want to fiddle with crontabs and keep it cross-platform, rather than doing ./script.rb & you could look into Process.fork something like $ cat runevery30mins.rb #!/usr/bin/env ruby Process.fork do loop generate_rss_feed sleep(30 * 60) end end then simply $ ./runevery30mins.rb $ It will immediately exit but fork into another process that will generate a new rss feed every 30 minutes Obviously you may want to add some way of stopping it (short of killing it) perhaps with Drb. On Fri, 12 Nov 2004 03:03:17 +0900, Francis Hwang wrote: > Cool! Funny that stuff isn't in the man page. Thanks much. > > > > On Nov 11, 2004, at 9:09 AM, Florian Frank wrote: > > > On 2004-11-11 22:44:51 +0900, Francis Hwang wrote: > >> So then I was thinking: Can I have a config that automatically edits > >> the crontab? Has anybody used Ruby to programmatically edit a crontab? > >> I suppose the brute force way to do it is to call "crontab -e" and > >> send the various keystrokes to stdin, but I wonder if anybody knows of > >> a less duct-tapey way. > > > > You can install a new crontab with > > $ crontab filename > > or > > $ crontab - > > for stdin input. > > > > You can output the current crontab of $USER with > > $ crontab -l > filename > > > > Of course you can do this in a ruby script, too. In this case you > > should > > perhaps use a lock file. > > > > If you only want to run a script every 30 minutes with cron, you > > can add a line like > > */30 * * * * /path/to/script.rb > > to your crontab. This is actually one of the main reasons to install > > something like cron. > > > > -- > > Florian Frank > > > >