From owner-freebsd-questions@freebsd.org Thu Nov 9 15:06:25 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E643E52A32 for ; Thu, 9 Nov 2017 15:06:25 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from smtp.fagskolen.gjovik.no (smtp.fagskolen.gjovik.no [IPv6:2001:700:1100:1:200:ff:fe00:b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.fagskolen.gjovik.no", Issuer "Fagskolen i Gj??vik" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 93EE569D36 for ; Thu, 9 Nov 2017 15:06:24 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from mail.fig.ol.no (localhost [127.0.0.1]) by mail.fig.ol.no (8.15.2/8.15.2) with ESMTPS id vA9F6Fkc075157 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 9 Nov 2017 16:06:15 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) Received: from localhost (trond@localhost) by mail.fig.ol.no (8.15.2/8.15.2/Submit) with ESMTP id vA9F6Fba075154 for ; Thu, 9 Nov 2017 16:06:15 +0100 (CET) (envelope-from trond@fagskolen.gjovik.no) X-Authentication-Warning: mail.fig.ol.no: trond owned process doing -bs Date: Thu, 9 Nov 2017 16:06:15 +0100 (CET) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= Sender: Trond.Endrestol@fagskolen.gjovik.no To: FreeBSD questions Subject: Re: Need help with rc.d script In-Reply-To: <5A046C46.4020807@gmail.com> Message-ID: References: <20171108021900.W9710@sola.nimnet.asn.au> <20171108043726.N72828@sola.nimnet.asn.au> <5A01F758.1050706@gmail.com> <20171109005843.E72828@sola.nimnet.asn.au> <5A0332D1.90509@gmail.com> <20171109013818.GA31584@FreeBSD> <20171109040452.d3c25fe2.freebsd@edvax.de> <20171109185331.B72828@sola.nimnet.asn.au> <5A046C46.4020807@gmail.com> User-Agent: Alpine 2.21 (BSF 202 2017-01-01) Organization: Fagskolen Innlandet OpenPGP: url=http://fig.ol.no/~trond/trond.key MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on mail.fig.ol.no X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Nov 2017 15:06:25 -0000 On Thu, 9 Nov 2017 09:55-0500, Ernie Luzar wrote: > Thanks for everyones input. But still the service stop command can not find > the pid file. > > In a effort for everyone to play with this problem on their own computers I > have simplified things as shown below. > > > >cat /usr/local/sbin/testloop > > #!/bin/sh > > ( > while true; do > echo -e "Success:" > logger -t testloop -p daemon.err "Success: log" > sleep 10 > done > ) & > echo $! > /var/run/dynip.pid Shouldn't this be /var/run/testloop.pid? > exit 0 > > The above is what Iam said to try. > > >cat /usr/local/etc/rc.d/testloop > > #!/bin/sh > # > # > # PROVIDE: testloop > # REQUIRE: LOGIN DAEMON NETWORKING > # KEYWORD: nojail shutdown > # > # Add the following line to /etc/rc.conf to enable testloop: > # > # testloop_enable="YES" > # > > . /etc/rc.subr > name="testloop" Or maybe you should name this dynip? > rcvar=testloop_enable > pidfile="/var/run/${name}.pid" > command="/usr/local/sbin/${name}" > load_rc_config ${name} > run_rc_command "$1" > > service testloop onestart does indeed start testloop as a daemon. Can verify > that by using the ps command. But there is no /var/run/testloop.pid created, > and the service testloop onestop command still complains about it not running > no pid file. -- Trond.