From owner-freebsd-rc@FreeBSD.ORG Mon Feb 5 22:32:09 2007 Return-Path: X-Original-To: freebsd-rc@freebsd.org Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8640416A498 for ; Mon, 5 Feb 2007 22:32:07 +0000 (UTC) (envelope-from zcwalinski@metroland.com) Received: from server05.metroland.com (server05.metroland.com [192.206.149.20]) by mx1.freebsd.org (Postfix) with ESMTP id A935113C4C4 for ; Mon, 5 Feb 2007 22:31:55 +0000 (UTC) (envelope-from zcwalinski@metroland.com) Received: from server06.metroland.com (tem-xchange-srv.tem.metroland.com [66.207.103.173] (may be forged)) by server05.metroland.com (8.13.1/8.13.1) with ESMTP id l15M15n5011647 for ; Mon, 5 Feb 2007 17:01:05 -0500 (EST) (envelope-from zcwalinski@metroland.com) Received: from CSYS-EVS01.corp.metroland.com ([10.151.25.36]) by server06.metroland.com (8.11.3/8.11.1) with ESMTP id l15MDJh30901 for ; Mon, 5 Feb 2007 17:13:20 -0500 (EST) (envelope-from zcwalinski@metroland.com) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Date: Mon, 5 Feb 2007 17:02:26 -0500 Message-ID: <5CD1A0226571E74A830A15192855981801964429@CSYS-EVS01.corp.metroland.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: I need help with Script running as a daemon !!! Thread-Index: AcdJcVIZPKrrWsuyTxCDrFojpcbj3g== X-Priority: 1 Priority: Urgent Importance: high From: "Cwalinski, Zygmunt" To: Subject: I need help with Script running as a daemon !!! X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2007 22:32:10 -0000 Hi, I am a new user to FreeBSD. All is new for me but I try to learn more and more everyday. I have to run a script as a daemon. Nice job for first time user :) Unfortunately I have to run more sophisticated daemon then this below but I can't even mange this simple daemon. Fortunately I have just found this mailing list and I hope I will get some help from you. I am trying to run the following script "runtest" as a daemon -------------------------------------------------------------- while true do sleep 1 done My daemon script: ----------------- #!/bin/sh . /etc/rc.subr # PROVIDE: Test # REQUIRE: DAEMON # BEFORE: LOGIN # KEYWORD: My test name=3D"runtest" pidfile=3D"/var/run/${name}.pid" rcvar=3D`set_rcvar` start_postcmd=3Druntest_poststart command=3D"sh /etc/runtest" command_args=3D"&" command_interpreter=3Dyes load_rc_config $name runtest_enable=3D${runtest_enable-:NO} runtest_poststart() { echo $! > ${pidfile} } run_rc_command "$1" When I start above daemon I get: ------------------------------------ test# sh /usr/local/etc/rc.d/runtestd start eval: cannot open sh: No such file or directory [: !=3D: argument expected [: sh: unexpected operator Starting runtest. and runtest script is running. Then I try to stop it and I get the following information: ---------------------------------------------------------- test# sh /usr/local/etc/rc.d/runtestd stop eval: cannot open sh: No such file or directory [: !=3D: argument expected runtest not running? (check /var/run/runtest.pid). runtest.pid does exists and there is correct process ID for my script What am I doing wrong? Please help me with it as I have spent few days already. Zyggi