From: Rogue Amateur Date: 2006-07-12T01:21:20+09:00 Subject: Re: Nuby Q: Daemonize (other materials have been read!) First, let me say thank you for the help. unknown wrote: > On Wed, 12 Jul 2006, Rogue Amateur wrote: > [snip] > > here is a script which can be used on the command line to daemonize any > other process: > > harp:~ > cat daemon.rb > #! /usr//bin/env ruby > fork{ > STDIN.reopen(STDOUT.reopen(STDERR.reopen(open('/dev/null','r+')))); > fork{ system ARGV.join(' ') ? exit : abort } and exit! } > > use it like > > harp:~ > daemon.rb any_other_command Ok, ignorance again: 1) this means I can't do the fork within the script itself? 2) suppose the any_other_command isn't in the default ruby library? do I supply the full path to call? Will it allow me to pass along arguments? (I'll be trying it, as I await a response...) > >> FYI: I also need to figure out how to reset the userid and groupid, but >> I have a book. :) > > you cannot do this from withint a script [snip] > my inclination would be to say that if you are reading > about it > you shouldn't use it! ;-) Gotcha. So the follow on question is: if I need my now isolated process to run as a particular user/group, the process is...? What? My local guru, who speaks about 15 levels too high for me, said "set the user and group ids." See, I can parrot! :) I'm familiar with sudo, but... would that work with the daemon.rb? (eg: sudo daemon.rb My_Ruby_Script.rb [arg] [arg]...) Thanks again Rogue Amateur -- Posted via http://www.ruby-forum.com/.