Date: Mon, 5 Feb 2007 16:55:56 -0600 From: Brooks Davis <brooks@freebsd.org> To: "Cwalinski, Zygmunt" <zcwalinski@metroland.com> Cc: freebsd-rc@freebsd.org Subject: Re: I need help with Script running as a daemon !!! Message-ID: <20070205225556.GB53516@lor.one-eyed-alien.net> In-Reply-To: <5CD1A0226571E74A830A15192855981801964429@CSYS-EVS01.corp.metroland.com> References: <5CD1A0226571E74A830A15192855981801964429@CSYS-EVS01.corp.metroland.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--JP+T4n/bALQSJXh8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 05, 2007 at 05:02:26PM -0500, Cwalinski, Zygmunt wrote: > 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. >=20 > I am trying to run the following script "runtest" as a daemon > -------------------------------------------------------------- > while true > do > sleep 1 > done >=20 > 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} >=20 > runtest_poststart() { > echo $! > ${pidfile} > } > run_rc_command "$1" >=20 > 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. >=20 > and runtest script is running. >=20 > 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). >=20 > runtest.pid does exists and there is correct process ID for my script >=20 > What am I doing wrong? > Please help me with it as I have spent few days already. You need to write a runtest_start() that runs the command and immediatly create the PID file. Note that for ${command} to work at all it must be an absolute path to something with the execute bit set. -- Brooks --JP+T4n/bALQSJXh8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFx7X8XY6L6fI4GtQRAvZ5AJ4jpzIoihtHENg8r09D8xOq8lAvjwCgtHL8 XMIXPNRHaCCyqcEHizWCY14= =uj/A -----END PGP SIGNATURE----- --JP+T4n/bALQSJXh8--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070205225556.GB53516>