Sponsored Content
Full Discussion: Bash Trap Problem?
Top Forums Shell Programming and Scripting Bash Trap Problem? Post 302259154 by jsabino on Monday 17th of November 2008 11:22:08 AM
Old 11-17-2008
Great, thanks Jim, I'll try that. As a follow-up, your code assumes that all 3 of these processes will be running. In actuality, the beginning of my script is a bit interactive in that it first asks the user whether or not they want process 1/2/3 to run.

Having said that, I'm thinking that this trap would try and kill a process that may or may not be running, how might it be modified to first check if that particular process is running (e.g., the user answered Yes to that question at the beginning) and if so, then issue the kill?

Regards,
JS
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trap command problem

I am having a unix script which in turns calls another unix script. Both are creating some temp files in /tmp which are supposed to be deleted after the end of each run In the child script if I have statement like trap "rm -f $messagefile" EXIT A similar statement is there in parent... (3 Replies)
Discussion started by: superprogrammer
3 Replies

2. Shell Programming and Scripting

how to trap unix signal if the process killed/interupt occured in bash...

hey champs, I have a process running.......i have to catch/trap the signal when the process is being interupted/killed (kill -9 pid) option...... how can i achieve the same thru my process........ let my process is a.sh and it supposed to take 13 mins to complete, but due to some problem ,... (15 Replies)
Discussion started by: manas_ranjan
15 Replies

3. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

4. Shell Programming and Scripting

Record the Signal Type or Number in Bash Trap function

In my Bash script I have an exit/cleanup function in a trap statement like: trap exitCleanup 1 2 3 6 15 25 Is there anyway to capture which signal # has occurred to record in a log file. Please note I am trying to avoid something like: trap 'mySignal=1; exitCleanup' 1 trap... (1 Reply)
Discussion started by: ckmehta
1 Replies

5. Shell Programming and Scripting

Trap Command Problem

Hi All , Could you please help me in resolving the below problem. I have 2 Script file say Scrip1.sh Script2.sh. Initially Script1.sh is started executed and inside the script1 , SIGINT is trapped to a separate cleanup process and exit. While Script1.sh is started executing ,... (1 Reply)
Discussion started by: sundar_ranga
1 Replies

6. Shell Programming and Scripting

trap CTRL-C problem

I am trying to trap CTRL-C, now the program I call has it's own exit message, I think this is the problem .. This is what I have now : function dothis { echo 'you hit control-c' exit } function settrap { trap dothis SIGINT } settrap until false; do ./ITGRecv.exe doneDoing this I... (2 Replies)
Discussion started by: Pmarcoen
2 Replies

7. Shell Programming and Scripting

How to trap set -o nounset in bash

I have a bash script using "set -o nounset" to prevent unset variables. However I have created a trap to run some cleanup options upon exit of the script which works fine for CTRL-C, etc. but if it hits and unset variable the trap does not run and the script bails out without having tidied up... (3 Replies)
Discussion started by: jelloir
3 Replies

8. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

9. Shell Programming and Scripting

Bash - trap error file not found

Hello. In bash, is there a way to trap error "file not found" when a script call another script which is not found; then abort. Example ( part of script running with -x option set) : + return 0 + RETURN_CODE=0 + ] + /root/bin/200_yast_install/00_reset_yast_install bash:... (5 Replies)
Discussion started by: jcdole
5 Replies

10. Solaris

Solaris 10 boot problem - ERROR: Last Trap: Fast Data Access MMU Miss

Hello, We have a T5140 server with Solaris 10 and its suddenly throwing "segmentation core" when I login into the server and not showing any output for commands like df, mount etc. so I had to reboot the server to fix this issue. Please note that there's no boot disk mirroring. But... (2 Replies)
Discussion started by: prvnrk
2 Replies
kill(1) 						      General Commands Manual							   kill(1)

Name
       kill - send a signal to a process

Syntax
       kill [-sig] processid...
       kill -l

Description
       The command sends the TERM (terminate, 15) signal to the specified processes.  If a signal name or number preceded by `-' is given as first
       argument, that signal is sent instead of terminate.  For further information, see

       The terminate signal kills processes that do not catch the signal; `kill -9 ...' is a sure kill, as the KILL (9) signal cannot  be  caught.
       By convention, if process number 0 is specified, all members in the process group (that is, processes resulting from the current login) are
       signaled.  This works only if you use and not if you use To kill a process it must either belong to you or you must be superuser.

       The process number of an asynchronous process started with `&' is reported by the shell.  Process numbers can also be  found  by  using	It
       allows job specifiers ``%...''  so process ID's are not as often used as arguments.  See for details.

Options
       -l   Lists  signal  names.  The signal names are listed by `kill -l', and are as given in /usr/include/signal.h, stripped of the common SIG
	    prefix.

See Also
       csh(1), ps(1), kill(2), sigvec(2)

																	   kill(1)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy