command to use if someone killed the script in between?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting command to use if someone killed the script in between?
# 1  
Old 11-04-2009
command to use if someone killed the script in between?

Hi All,

I want to know about what command i can use so that it should run the below mentioned line if somebody killed the process when i run my script...

the command to run once my script is killed is

Code:
\rm -rf $LOCKDIR

Thank you
# 2  
Old 11-04-2009
You can use trap - but you cannot trap all signals
Code:
trap "rm -rf $LOCKDIR"  [signal to trap goes here, example INT for ctrl/c interrupt]

kill -l ( that is a lowercase ELL) will show the signal names on your system.
# 3  
Old 11-04-2009
yes i want command for ctrl/c type of interceprion...

if i want to use the trap then where do i need to use that? before the script starts?

---------- Post updated at 07:36 PM ---------- Previous update was at 07:06 PM ----------

I have seen this command somewhere in the script which i already has...

Code:
trap "cleanup; exit" 0 1 2 3 15

could you please tell me what this actually means?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Machine rebooting when shell script is killed

I am trying to kill a shell script by grepping it, but the machine is being shutdown totally when i kill it Below is the code kill `ps -ef |grep test.sh| grep -v grep` stat=$? if # check the return code then echo " script killed at $(date +%D@%T) " else echo " script... (5 Replies)
Discussion started by: venu
5 Replies

2. Shell Programming and Scripting

Running at command - Parent script getting killed

I have a script that calls another script within it that takes about 1 hour to execute. I am noticing that the parent script that calls the child script is getting killed. Does anyone know why? The child script still runs. (3 Replies)
Discussion started by: 3junior
3 Replies

3. AIX

After run ps , uptime , w command I get reply "killed"

Hi, After run ps , uptime , w command I get reply "killed" as normal dba and staff group user. As root every command works fine. I cheched all the user settings , right with other servers and I could not find any error and other settings. The oslevel is 5300-10-01-0921. Any idea to... (12 Replies)
Discussion started by: boki
12 Replies

4. Shell Programming and Scripting

Script which can send mail after its been killed

Hi Everyone, I want an script which sends mail after its been killed. Thanks (3 Replies)
Discussion started by: aki41187
3 Replies

5. Shell Programming and Scripting

Killed by signal 15.

Hi all I have Master script, Main script ,and 4 Child script. Master.sh #!/bin/bash /export/home/user/Main.shMain.sh #!/bin/bash /export/home/user/Child1.sh & /export/home/user/Child2.sh & /export/home/user/Child3.sh & /export/home/user/Child4.sh &I run only Master.sh script... (1 Reply)
Discussion started by: almanto
1 Replies

6. UNIX for Advanced & Expert Users

ls is being killed

Hi There, Hope anyone can give me a hand on AIX oslevel -r 5300-05 Try to "ls *sh" from folder and it return killed, is there any clue on that? 1. perform ls and count ls * | wc -l 0 ksh: 561582 Killed 2. without provide "*" wildcard, the result can be return ls | wc ... (7 Replies)
Discussion started by: darkrainbow
7 Replies

7. Solaris

Port used needs to be killed

Hi, We are using oracle 10g in a Solaris box. The same box has Informatica also installed. But it runs on port 6001. But whenever the server is restarted the Oracle database picks up the port 6001 and does not allow Informatica to be started. But I am have no clue of which Oracle process is... (2 Replies)
Discussion started by: chrisanto_2000
2 Replies

8. UNIX for Dummies Questions & Answers

I'm getting killed and I don't know why.

UPDATE: I think I may have a culprit. I had KDE console history to unlimited, and since there's a lot of output... I'm thinking that may be it. I'd still like to hear advice on how to figure out why processes get killed, if anyone has any! though ****************** There's this script I run... (1 Reply)
Discussion started by: tphyahoo
1 Replies

9. UNIX for Dummies Questions & Answers

process not getting killed

I have a process that is in the sleeping state "S" and I have tried to stop it with a run control script that I use to stop/start it - but it does not stop. I have tried kill -9 <PID of process> with no change. I imagine that this process is sleeping with the kernel. It does not respond to... (5 Replies)
Discussion started by: finster
5 Replies
Login or Register to Ask a Question