> On a side note, I would write this snippet rather like this:
>
>   Dir.chdir(ENV['HOME'])
>
>   filename = "importantfile.rb"
>   unless File.exists?(filename)
>     File.open(filename, "w") {|file| file.print("something") }
>   end

I use random codes just to give an example of what I'm talking about.

On the other hand, What I meant to ask is how do you use daemon to run a 
ruby script in the background

The following example didn't work for me

ruby myserver_control.rb start

I get:
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/daemonize.rb:11:in
 `fork': fork() function is unimplemented on this machine 
(NotImplementedError)
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/daemo
nize.rb:11:in `safefork'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/daemo
nize.rb:93:in `daemonize'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/appli
cation.rb:146:in `start_load'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/appli
cation.rb:298:in `start'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/contr
oller.rb:70:in `run'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons.rb:14
7:in `block in run'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/cmdli
ne.rb:109:in `call'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons/cmdli
ne.rb:109:in `catch_exceptions'
        from 
C:/Ruby200/lib/ruby/gems/2.0.0/gems/daemons-1.1.9/lib/daemons.rb:14
6:in `run'
        from aemons.rb:3:in `<main>'

-- 
Posted via http://www.ruby-forum.com/.