Killing child process in ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Killing child process in ksh
# 1  
Old 10-09-2007
Killing child process in ksh

I have a script that (ideally) starts tcpdump, sleeps a given number of seconds, then kills it.

When I do this for 10 seconds or and hour, it works fine. When I try it for 10 hours (the length I actually want) it just doesn't die, and will actually stick around for days.

Relevant part of my script:

secondstime=$(($HOURSRUN * 60 * 60))
tcpdump -ni hme0 -w ${LOGDIRECTORY}${LOGFILE}`date +%m%d`.log -F $EXPRESSIONFILE&
sleep $secondstime
kill %1

Using 'ps', I can see that sleep got the right number of seconds. My ksh version is: @(#)PD KSH v5.2.14 99/07/13.2

Any ideas or better ways to do this would be appreciated.
# 2  
Old 10-09-2007
maybe use kill -9, not great practise but will definately kill it. Might be worth creating a cron job to perform the command if it's something you're going to be doing on a regular basis for 10 hours.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh child process not ignoring SIGTERM

My ksh version is ksh93- =>rpm -qa | grep ksh ksh-20100621-3.fc13.i686 I have a simple script which is as below - #cat test_sigterm.sh - #!/bin/ksh trap 'echo "removing"' QUIT while read line do sleep 20 done I am Executing the script From Terminal 1 - 1. The ksh is started... (3 Replies)
Discussion started by: rpoornar
3 Replies

2. Solaris

Child killing parent process and how to set up SMF

Hello, A little background on what we are doing first. We are running several applications from a CLI, and not all of them are fully functional. They do on occasion core dump, not a problem. We are running a service that takes a screen scrape of those apps and displays them in a more user... (5 Replies)
Discussion started by: Bryan.Eidson
5 Replies

3. Shell Programming and Scripting

forking a child process and kill its parent to show that child process has init() as its parent

Hi everyone i am very new to linux , working on bash shell. I am trying to solve the given problem 1. Create a process and then create children using fork 2. Check the Status of the application for successful running. 3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies

4. Red Hat

Killing child daemon started by parent process

Hi All, Hope this is right area to ask this question. I have a shell script (bash) "wrapper.sh", which contains few simple shell command which executes a "server.sh" (conatins code to execute a java server) as a daemon. Now what I want to kill this "server.sh" so that the server should... (2 Replies)
Discussion started by: jw_amp
2 Replies

5. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

6. Shell Programming and Scripting

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

7. UNIX for Advanced & Expert Users

killing all child processes

Hi, Is there a way I can kill all the child processes of a process, given its process id. Many thanks in advance. J. (1 Reply)
Discussion started by: superuser84
1 Replies

8. Shell Programming and Scripting

killing a child process

I am calling another script from my main script and making it run in the background,based upon the value of the input provided by the user I want to kill the child process ,I have written this code timer.ksh & PID=$$ print "\n Do you wish to continue .. (Y/N) : \c " read kill_proc if ]... (4 Replies)
Discussion started by: mervin2006
4 Replies

9. Shell Programming and Scripting

In ksh, how does an in-line child sub-process get its own PID?

This is not the same as a few of the other posted items dealing with sub-process pids (that I saw anyway). If zot contains: echo "main mypid: $$ - lastpid: $!" ( echo "block mypid: $$ - lastpid: $! - ppid: $PPID" ps -ef > xxx sleep 5 echo "block mypid: $$ - lastpid: $! - ppid:... (6 Replies)
Discussion started by: MichLab
6 Replies

10. Shell Programming and Scripting

killing a child process within a shell

Hi All, I have a written a script in korn shell for importing data into a oracle database. The shell invokes the import within the script. I want to kill this import (child process) . I tries using trap, but this does not kill the import even if i press cnt c. i have to login into other terminal... (2 Replies)
Discussion started by: yerics
2 Replies
Login or Register to Ask a Question