08-29-2009
Killing the Wrong Background Process
BASH on Solaris
Hi All,
I posted a problem whereby I was looking to Kill a background (calling Send)mail) process after a certain time had elapsed.
A User Scottn very kindly provided a useful function to do this as below
CheckAndKill()
{
sleep "$EMAIL_TIMEOUT_THEN_KILL"
[ "$(ps | awk '$1 == '$1)" ] && echo "Killing process $1" && kill -9 "$1"
}
Howvere I am calling this in the wrong way as below:
send_email "Warning Notification" $warning_msg" | tee -a "$LOG_PATH"/email_output.lst &
CheckAndKill $! &
When I check the shell output I can see that I am killing the wrong process ie I am killing the "tee" not the actual send_email function.
The $! passed into CheckAndKill() is clearly picking on the process id of the tee and not the send_email function
Any ideas how to correctly kill the send_email function?
Kind Regards
Satnam
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
What option is used with kill to cause the server to reread its config file. (16 Replies)
Discussion started by: jo calamine
16 Replies
2. UNIX for Dummies Questions & Answers
I can kill running processes on my linux red hat system using ctrl-c but cannot do it from command line of another terminal using kill -2 pid. Although I can kill them from command line using kill -9 pid and other signals. I would like to do it using the kill -2 pid.
Thanks for your suggestions (6 Replies)
Discussion started by: bbhayana
6 Replies
3. Shell Programming and Scripting
Hi Friends,
I am new to this forum as well as new to shell scripting.
I have a problem here and i need someone to solve this.
Let us consider there are two processes(abc & def).There is a script which kills these two processes(i.e killtheprocess abc). Here abc is the argument .
There is a... (1 Reply)
Discussion started by: Prince89
1 Replies
4. UNIX for Dummies Questions & Answers
Hi,
First, I am running a scipt.While the script is running I realize that I dont want the script to be run so I am killing the script externally.Before the process gets terminated or killed it should delete all the temporary files created by the script.How to do this?Can anyone help me?
... (3 Replies)
Discussion started by: arthi
3 Replies
5. Shell Programming and Scripting
Hi friends,
i m in big trouble....
i have one script which connects two server ...like below..
script1.sh
-------------------------------------
bash test.sh &
eval x=$@
export x=`echo $x`
#echo $x
#
ssh user@8.2.5.6 bash /mbbv/location/script.sh $x|sed '/Binary file/d'... (1 Reply)
Discussion started by: Shahul
1 Replies
6. Shell Programming and Scripting
I had issues with processes locking up. This script checks for processes and kills them if they are older than a certain time.
Its uses some functions you'll need to define or remove, like slog() which I use for logging, and is_running() which checks if this script is already running so you can... (0 Replies)
Discussion started by: sukerman
0 Replies
7. UNIX for Dummies Questions & Answers
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
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
Hi ,
I have a list of application process id's.
Is there a way to kill all the process listed below using the script, except the once which are starting with " Genesis "
adm 1522 ABC_Process.tra
adm 1939 Genesis_Process.tra
adm 2729 Genesis_Archive.tra
adm 3259 xyz_Process.tra (5 Replies)
Discussion started by: murali1687
5 Replies
10. Shell Programming and Scripting
I played a bit around with the Terminal and I observed something.
When I start and kill a background process, there is some kind of output. After I invoked the command to start the process the first message " 13063" is directly displayed. However, after killing the process, the second message "+... (3 Replies)
Discussion started by: Chuck Morris
3 Replies
LEARN ABOUT OSF1
dxproctuner
dxproctuner(8) System Manager's Manual dxproctuner(8)
NAME
dxproctuner - Manages and monitors system processes
SYNOPSIS
/usr/bin/X11/dxproctuner
OPTIONS
Process Tuner accepts all of the standard X Toolkit command line options, which are documented in the OPTIONS section in the X(1X) refer-
ence page.
DESCRIPTION
The Process Tuner application, dxproctuner, is used to monitor and manage processes.
Use Process Tuner to: Display a list of processes and their characteristics Display the processes running for yourself or all users Display
and modify process priorities Send a signal to a process
The Process Tuner application can be invoked from the CDE Application Manager from the following categories:
Application Group: System_Admin
System Admin Subgroup: MonitoringTuning
EXAMPLES
To start Process Tuner from the command line, enter: dxproctuner You can view the Process Tuner online help volume without running the
application. To open the Process Tuner help volume from the command line, enter the following command: /usr/dt/bin/dthelpview -h
/usr/dt/appconfig/help/C/Dxproctuner.sdl
FILES
Contains user preferences that control the appearance of the application Contains the Process Tuner application executable Contains the
Process Tuner help volume Contains the default values for the application's X resources
SEE ALSO
Commands: kill(1), ps(1), X(1X)
System Calls: exit(2), kill(2), sigaction(2)
Files: signal(4)
dxproctuner(8)