Date: Tue, 24 Sep 2002 11:02:42 +0100 From: Daniel Bye <dan@slightlystrange.org> To: freebsd-questions@freebsd.org Subject: Re: Writing a start / stop script (getting pid) Message-ID: <20020924100241.GA1089@catflap.home.slightlystrange.org> In-Reply-To: <32468.1032860433@www23.gmx.net> References: <32468.1032860433@www23.gmx.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Sep 24, 2002 at 11:40:33AM +0200, Pascal Giannakakis wrote: > Lo ppl, > > how to i get the pid of a process i start in a shellscript? > > The Variables $$ / $PID are not really of use. What i would like to have, is > some sort > of command with has the return value of another startet script. > > The background: i try to write a rc.d script for ftpd, and i need the PID to > stop it > again. If you are using the ftpd that comes in the base system, it can be made to write its PID out to file - start it with the options -D -p /path/to/pidfile You can then kill the process by PID by saying kill `cat /path/to/pidfile` If you are not using the base system's ftpd, try this: kill `ps axfr | awk '/ftpd/ {print $1}'` Or, if you have more than one running, for pid in `ps axfr | awk '/ftpd/ {print $1}'`; do kill $pid done Just one way to do it, but one that works for me! HTH Dan -- Daniel Bye PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc PGP Key fingerprint: 3D73 AF47 D448 C5CA 88B4 0DCF 849C 1C33 3C48 2CDC _ ASCII ribbon campaign ( ) - against HTML, vCards and X - proprietary attachments in e-mail / \ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020924100241.GA1089>