[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: daemonizing a command



On Thu, May 27, 2010 at 9:59 PM, Neal Hogan <nealhogan@gmail.com> wrote:
> On Thu, May 27, 2010 at 2:52 PM, Israel Garcia <igalvarez@gmail.com> wrote:
>> Hi,
>>
>> I need to daemonize this command on a debian lenny?
>>
>> ruby apd.rb
>>
>> It's a simple app for my network.
>>
>> I was thinking to use nohup ruby app.rb & at rc.local, but I want to
>> know if there's other ways to do it.
>
> It's been awhile since I wrote such a script, so the details aren't at
> the tip of my tongue, but the following helped me when I did. Perhaps
> it will help.
>
> http://www.debian-administration.org/article/Making_scripts_run_at_boot_time_with_Debian
Hi Neal,

I did it this way.. look my init script :-)

#! /bin/sh
# /etc/init.d/apd
#

# Some things that run always

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting postfix policy daemon...."
    sleep 1
    ruby /usr/local/bin/apd.rb & > /dev/null
    echo ""   > /dev/null
    ;;
  stop)
    echo "Stopping postfix policy daemon...."
    sleep 1
     kill -9 `ps afx|grep "ruby /usr/local/bin/apd.rb"|grep -v
grep|awk '{print $1}'` >/dev/null
    ;;
restart)
        $0 stop
        sleep 1
        $0 start
        ;;
  *)
    echo "Usage: /etc/init.d/apd {start|stop|restart}"
    exit 1
    ;;
esac

exit 0

>
>>
>> --
>> Regards;
>> Israel Garcia
>>
>>
>> --
>> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
>> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>> Archive: [🔎] AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail.gmail.com">http://lists.debian.org/[🔎] AANLkTildF701nd0CdWoEgVXJP56o3M7H3ZSzqG882vcC@mail.gmail.com
>>
>>
>



-- 
Regards;
Israel Garcia


Reply to: