Path: utzoo!attcan!uunet!virtech!rdg From: rdg@virtech.uucp (Roger D. Gough) Newsgroups: comp.lang.c Subject: Re: Getting PID of background process in shell script. Summary: Easy. Message-ID: <1990Mar24.195613.5103@virtech.uucp> Date: 24 Mar 90 19:56:13 GMT References: <3074@auspex.auspex.com> Reply-To: rdg@virtech.UUCP (Roger D. Gough) Organization: Sequel Technologies Lines: 15 In article <3074@auspex.auspex.com> hitz@auspex.auspex.com (Dave Hitz) writes: >In a shell script I want to start a process in the background and then >kill it at some later time. To do this I want to save it's pid in a >variable. > The builtin shell variable $! contains the process number of the last process run in the background. So you want to do something like: run a command & PID=$! # do some stuff kill $PID -- Roger D. Gough +1 703 689 1692 Sequel Technologies uunet!sequel!rdg