Writing Ruby Daemons
We got some bash scripts running via a cronjob to set permissions of certain directories. To improve this process I wrote a very simple ruby daemon process to handle this.
First I installed the daemons gem (#gem install daemons), next I created the following:
#control.rb
require ‘rubygems’
require ‘daemons’
Daemons.run(’permissions.rb’)
———————————————————————-
#permissions.rb
loop do
system(’<some unix commands’>
system(’<some unix commands’>
sleep 15
end
As you can see, I use the standard unix tools by invoking the system(”) command. I am still trying to find out if it would be benefitial to use File.chmod and File.chown from the fileutils package.
September 12th, 2007 at 11:06 pm
Hi Sander,
Did you know that NetBeans IDE 6.0 will have Ruby support. Gails and I moved over to Ruby recently. Its pretty cool.
September 13th, 2007 at 8:41 am
Hi Chris,
Thanks for your comment. I’ve seen some posts about ruby and NetBeans. However till now I have been using Ruby mainly as a replacement for standard bash scripts.
For example, I wrote a view scripts that automatically installs our CMS software onto a clients website (Copying files, loading mysql db’s, setting permissions and file ownership etc.). However I have not been using Ruby Rails or Jruby yet and all my scripts are written in unix vi and run on the cli
July 1st, 2008 at 3:16 pm
Thanks for this — Daemons has worked out well in an application I am writing.