How should I add a timeout to my scripts?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How should I add a timeout to my scripts?
# 1  
Old 11-05-2008
How should I add a timeout to my scripts?

I am running several tcsh scripts in the crontab of my workstation for acquiring, processing and visualizing data. Some of the quicklooks generated by these scripts are automatically copied to an intranet page.

However, I just found out that I have currently about 50 (old) scripts still running because the intranet server is down for the moment. In that case, the scripts hangs on the copy/move actions I inserted. I killed them one by one, but would like to avoid that for the next time. Never thought of that, but is there a neat way to set a time out in my scripts or crontab to automatically kill it after some time? Or any other solutions?

Thanks in advance. Below are some lines from one of the scripts:

set input = /nobackup/users/sharkm/quicklooks
set infodir = /net/intranetserver/homepages/sharkm/pub_info/images

set infile = ${input}/current.jpg
cp $infile ${infodir}/current.jpg
# 2  
Old 11-05-2008

If you were using a Bourne-type shell:

Code:
timeout=600  ## 10 minutes
{
  : put script here
} &
sleep "$timeout"
kill $!

You'll find scripting (as well as getting help) easier if you use a POSIX shell. [T]csh is not recommended for scripting:

Top Ten Reasons not to use the C shell
C shell problems
Csh Programming Considered Harmful
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

2. Red Hat

TNS Timeout Error when connecting to SQLPLUS through scripts only

Hi, I am facing a strange issue when connecting to SQLPLUS via a shell scripts. I am using Linux 2.6.18-274.18.1 and gbash shell. When I connect to SQLPLUS through scripts then it throws TNS Time Out error ""sometimes"" and connects successfully other times.This is only happening when... (9 Replies)
Discussion started by: aashish.sharma8
9 Replies

3. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

4. Homework & Coursework Questions

Help on Add User Scripts

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: for each user Create a account formatted as last name first initial. Example (southerm) Ensure no... (0 Replies)
Discussion started by: moosemd
0 Replies

5. Shell Programming and Scripting

Add 5 lines of code to all the scripts in a directory

Hi Guys, I need some tips on writing a Korn shell script that would look for certain lines of code and replace all the scripts in the directory with a few other lines. I have about 120 scripts that I need to modify. Any suggestions would be appreciated! Thanks, Cool_avi (5 Replies)
Discussion started by: coolavi
5 Replies

6. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

7. Shell Programming and Scripting

SQL scripts not running, possible timeout issue?

I am a novice Unix scripter and need a little advice/help on a script I've written that's causing some problems. We are using Solaris 9 on a Sun box and the script is invoked with the korn shell. I have a two-part question: I wrote a shell script that calls and executes 3 separate sql scripts,... (3 Replies)
Discussion started by: E2004
3 Replies

8. UNIX for Dummies Questions & Answers

How to add email notification in scripts?

Hi. I want to add email notification so when the my script finishes it sends out an email of the results to our team. If there are errors the subject on the email should say there were errors. If any having idea/sample scripts pls share with me. (2 Replies)
Discussion started by: redlotus72
2 Replies

9. Solaris

About the Timeout

Hello everyone I am a new one,I want to know how to get the solaris force the loginer out if he do not in a time thanks (4 Replies)
Discussion started by: lyh003473
4 Replies

10. HP-UX

timeout

How can I kick a user out after being idle for a certain amount of time, would prefer not to use scripts, will TMOUT work on HP-UX? (5 Replies)
Discussion started by: csaunders
5 Replies
Login or Register to Ask a Question