Terminate shell script after a specified time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Terminate shell script after a specified time
# 8  
Old 10-14-2014
Dear cjcox,

This is an elegant solution, and the one-liner that can be inserted into any script. I didn't bother with PID=$$, I just issue the kill direct at $$ and it worked very well.

Smilie



Robin
# 9  
Old 10-15-2014
Quote:
Originally Posted by rbatte1
Dear cjcox,

This is an elegant solution, and the one-liner that can be inserted into any script. I didn't bother with PID=$$, I just issue the kill direct at $$ and it worked very well.

Smilie



Robin
There could be cases on old Unix especially where having a subprocess kill it's parent could result in a zombie... so might have to disassociate the subprocess using something like a nohup that disconnects from the pseudo tty, etc...

But in general, it works (everything is Linux nowadays)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Capture run time of python script executed inside shell script

I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
Discussion started by: Adfire
2 Replies

2. Shell Programming and Scripting

Run script every minute and terminate after specified number of executions

when it runs and look at my acron.log file it generates an error as below /tmp/prog.sh: line 4: (12 Replies)
Discussion started by: azherkn3
12 Replies

3. Shell Programming and Scripting

[Solved] Terminate TCPDUMP in a certain time period

Hello All, As I stated in subject, I need a command to terminate my tcpdump command in a certain time period. (using HP-UX) I am using below one to terminate when number of captured packages reach 3 limit. But what if there will no packet come in 5 min for instance? Please help me to find a... (2 Replies)
Discussion started by: mrcrowley
2 Replies

4. Shell Programming and Scripting

Terminate a process using shell script

Hi, I am writing a shell script to run a process and write the output of the process to a file. Inside program.sh: ./process.sh > tempfile .. open tempfile do the following But the problem is that process.sh is running indefinitely and program.sh is not executed completely. Can... (4 Replies)
Discussion started by: dreamgirl314
4 Replies

5. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

6. Shell Programming and Scripting

strange behaviour script terminate before complete execution

I'm working on a script to make backup of various folder located on various host using different OS. I got a strange behaviour because the script donět process all lines of a configuration file, the script execute only one loop even the input file have 6 lines: This is the script: #!/bin/bash... (4 Replies)
Discussion started by: |UVI|
4 Replies

7. Shell Programming and Scripting

Time Diff in shell script

Hi all , i am trying to calculate time difference btw the script execution I am using solaris start_time=`date +%s` sleep 2 end_time=`date +%s` duration=`expr $end_time - $start_time` when i try to subtract i get the error line 13: %s - -time : syntax error: operand expected... (3 Replies)
Discussion started by: posner
3 Replies

8. Shell Programming and Scripting

Get the time with shell script

when I get time some times it like $hwclock -r Mon 07 Jul 2008 20:01:48 PM GMT -0.486264 seconds some times it like $hwclock -r Mon Jul 7 20:01:48 2008 -0.547393 seconds the sequence is not the same all the time and I just want to use "hwclock" not "date" to get time I... (8 Replies)
Discussion started by: yanglei_fage
8 Replies

9. Shell Programming and Scripting

how to terminate ssh connection without terminating script

Hi all, I connect with SSH connection to remote machine in the script and ı want to logout at half of the script then continue to script. If ı write exit in the script it terminates script not SSH connection. How can i do that please help me (1 Reply)
Discussion started by: fozay
1 Replies

10. Shell Programming and Scripting

Terminate session on completing script

Hai all.. How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The... (4 Replies)
Discussion started by: deepsteptom
4 Replies
Login or Register to Ask a Question