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 DEBIAN
gnome-background-properties
gnome-background-properties(1) User Commands gnome-background-properties(1)
NAME
gnome-background-properties - customize your desktop background
SYNOPSIS
gnome-background-properties [gnome-std-options]
DESCRIPTION
The Background preferences tool allows you to customize the desktop background. The desktop background is the part of the desktop where
there are no interface graphical items, such as panels and windows. The desktop background is always beneath the other interface items.
You can customize the desktop background in the following ways:
o Select an image to display on the desktop background. The image is superimposed on the desktop background color. The desktop back-
ground color is visible if you select a transparent image or if the image does not cover the entire desktop background.
o Select a color for the desktop background. You can select a solid color, or create a gradient effect with two colors. A gradient
effect is a visual effect where one color blends gradually into another color.
OPTIONS
The following options are supported:
gnome-std-optionStandard options available for use with most GNOME applications. See gnome-std-options(5).
EXAMPLES
Example 1: Launching the background preference tool
example% gnome-background-properties
EXIT STATUS
The following exit values are returned:
0 Application exited successfully
>0 Application exited with failure
FILES
The following files are used by this application:
/usr/bin/gnome-backgrounExecutableefor Background preferences tool
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+------------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+------------------------------+
|Availability |SUNWgnome-desktop-preferences |
+-----------------------------+------------------------------+
|Interface stability |External |
+-----------------------------+------------------------------+
SEE ALSO
Preference Tools Manual
Latest version of the GNOME Desktop User Guide for your platform.
gnome-control-center(1), gnome-std-options(5)
NOTES
Written by Glynn Foster, Sun Microsystems Inc., 2003.
SunOS 5.10 2 Oct 2003 gnome-background-properties(1)