Sponsored Content
Top Forums Shell Programming and Scripting How to kill background process Post 302319423 by G.K.K on Monday 25th of May 2009 07:32:29 AM
Old 05-25-2009
How to kill background process

Hi,

I am new to scripting and learning. please share your knowledge with me.

I have a scenario, that i need to trace whether the background script is still running or not? if it was running i need to kill it. i am using the below scripts , but it is not working i dont know why Smilie. please help me to overcome this.

script1.sh
------------
#! bin/sh
echo "hai this is the world of unix"
sleep 200s

script2.sh
---------
#! bin/sh
sh script1.sh &
BGDP=$!

while [ BGDP > 0 ]
do
echo " still running"
kill $BGDP
done

out put from this script is:
still running
still running
.....

please help me to solve this.

Thanks in advance,
G.K.K
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

When kill doesnt work, how to kill a process ?

Hi All, I am unable to kill a process using kill command. I am using HP-UX system. I have tried with kill -9 and i have root privilages. How can i terminate this daemon ? ? ? Regards, Vijay Hegde (3 Replies)
Discussion started by: VijayHegde
3 Replies

2. Programming

kill(0,-9) don't kill the process

Hi all i have simple c program , when i wish to kill the app im using kill(0,-9) , but it seams this command don't do any thing and the program. just ignore it . what im doing wrong here ? im using HP-UX ia64 Thanks (9 Replies)
Discussion started by: umen
9 Replies

3. Shell Programming and Scripting

Kill a process without using kill command

Sorry, posted the question in other forum. (0 Replies)
Discussion started by: sudhamacs
0 Replies

4. Linux

Kill a process without using kill command

I want to Kill a process without using kill command as i don't have privileges to kill the process. I know the pid and i am using Linux 2.6.9 OS. (6 Replies)
Discussion started by: sudhamacs
6 Replies

5. Shell Programming and Scripting

kill PID running in background in for loop

Guys, can you help me in killing the process which is running in back ground under for loop I am not able to find the PID using ps -afx|grep <word in command I entered> (1 Reply)
Discussion started by: mohan_xunil
1 Replies

6. Solaris

Kill snoops running in background

Hi, I want to run 2 snoop commands in the background and would like to be able to kill them when I want to. What is the best way to do that at the command line? if I do a fg at the terminal, will that bring only the snoop that I got running myself so I stop them with a CTRL_C or will that... (2 Replies)
Discussion started by: Pouchie1
2 Replies

7. Linux

How to kill background process?

Hi I have one file one.sh. In one.sh file their are 5 perl script 1.pl, 2.pl, 3.pl,4.pl, 5.pl. I ran the one.sh file in background and now I want to kill the one.sh file after 5 min. but its not killing the processs. Please let me know how to kill the background process. (2 Replies)
Discussion started by: lakshmikant
2 Replies

8. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

9. Shell Programming and Scripting

How to put FTP process as a background process/job in perl?

Hi, I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming. So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies

10. Shell Programming and Scripting

Kill an specific process ID using the KILL and GREP commands

Good afternoon I need to KILL a process in a single command sentence, for example: kill -9 `ps -aef | grep 'CAL255.4ge' | grep -v grep | awk '{print $2}'` That sentence Kills the process ID corresponding to the program CAL255.4ge. However it is possible that the same program... (6 Replies)
Discussion started by: enriquegm82
6 Replies
bgerror(n)						       Tcl Built-In Commands							bgerror(n)

__________________________________________________________________________________________________________________________________________________

NAME
bgerror - Command invoked to process background errors SYNOPSIS
bgerror message _________________________________________________________________ DESCRIPTION
The bgerror command doesn't exist as built-in part of Tcl. Instead, individual applications or users can define a bgerror command (e.g. as a Tcl procedure) if they wish to handle background errors. A background error is one that occurs in an event handler or some other command that didn't originate with the application. For example, if an error occurs while executing a command specified with the after command, then it is a background error. For a non-background error, the error can simply be returned up through nested Tcl command evaluations until it reaches the top-level code in the application; then the application can report the error in whatever way it wishes. When a background error occurs, the unwinding ends in the Tcl library and there is no obvious way for Tcl to report the error. When Tcl detects a background error, it saves information about the error and invokes the bgerror command later as an idle event handler. Before invoking bgerror, Tcl restores the errorInfo and errorCode variables to their values at the time the error occurred, then it invokes bgerror with the error message as its only argument. Tcl assumes that the application has implemented the bgerror command, and that the command will report the error in a way that makes sense for the application. Tcl will ignore any result returned by the bgerror command as long as no error is generated. If another Tcl error occurs within the bgerror command (for example, because no bgerror command has been defined) then Tcl reports the error itself by writing a message to stderr. If several background errors accumulate before bgerror is invoked to process them, bgerror will be invoked once for each error, in the order they occurred. However, if bgerror returns with a break exception, then any remaining errors are skipped without calling bgerror. Tcl has no default implementation for bgerror. However, in applications using Tk there is a default bgerror procedure which posts a dialog box containing the error message and offers the user a chance to see a stack trace showing where the error occurred. In addition to allow- ing the user to view the stack trace, the dialog provides an additional application configurable button which may be used, for example, to save the stack trace to a file. By default, this is the behavior associated with that button. This behavior can be redefined by setting the option database values *ErrorDialog.function.text, to specify the caption for the function button, and *ErrorDialog.function.command, to specify the command to be run. The text of the stack trace is appended to the command when it is evaluated. If either of these options is set to the empty string, then the additional button will not be displayed in the dialog. SEE ALSO
after(n), tclvars(n) KEYWORDS
background error, reporting Tcl 7.5 bgerror(n)
All times are GMT -4. The time now is 02:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy