From: Francis Hwang Date: 2004-11-11T22:44:51+09:00 Subject: Writing a looping, low-configuration script in Ruby So I'm writing a one-file Ruby program that will generate an RSS feed every half-hour, and I want it to have as little configuration as possible. This is aimed both at Rubyists and newcomers who might be pulled into the Rubyverse by another well-targeted tool, so I'm trying to think of the clearest, easiest way that the user could configure this. So here's what I'm thinking: If this has to run every 30 minutes, the easiest way (for me, the programmer) to do this, is have the user run it as a backgrounded process: $ ./script.rb & but that's sort of fragile, particularly since (if I'm understand Unix process correctly) backgrounding is handled in the shell so you can't really log out without killing the background. Also, if you restart the web server you lose the process, too. 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. F.