Script to check for a file, check for 2hrs. then quit


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to check for a file, check for 2hrs. then quit
# 1  
Old 09-15-2005
Script to check for a file, check for 2hrs. then quit

I wish to seach a Dir for a specific file, once the file is found i will perform additional logic. If the file is not found within two hours, i would like to exit.

Logically, I'm looking for the best way to approach this

Thanks for any assistance in advance.

Note: I'm using a C shell and have a little exp with awk,sed and grep.
# 2  
Old 09-15-2005
Code:
#!/bin/csh -f
set now = 0
# set up any other variables
#
#================================
loop:
if (! -e "/tmp/myfile") then
 sleep 120 # wait 2 minutes
 @ now = $now +2
  if ($now > 120) goto files-missing # Waited two hours - giving up
  goto loop
endif
# Put what to do if you found the file here
# and then go to the end to exit
goto end-it-all
#===================
files-missing:
# You might want to send yourself an email that it didn't get the file
# or just drop through to end-it-all
end-it-all:
exit

# 3  
Old 09-16-2005
Thanks !!!!!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to check if file is placed

Hello, I am currently looking how to develop a script to monitor files placed in a particular folder. This is not actually a big deal as I usually do some perl and shell scripting, but my problem goes here: First, the folder names in which these files are being placed uses a naming convention of... (1 Reply)
Discussion started by: Wizard_1979
1 Replies

2. Shell Programming and Scripting

check file script

hi, i have a small file with 4 rows that looks like this: any_error_today= any_message_today= any_other_thing= any_other _thing= I want to write a script that checks if after any = there is no data(is empty), then everything is OK. If after = there is data written, for example... (6 Replies)
Discussion started by: arrals_vl
6 Replies

3. Shell Programming and Scripting

Script to check file exists

Hi, I am trying to write a script which checks if any file exists with "*.log" or "*.out" in Directory below is the code #------------------ path=/abd/xyz/ if ; then echo "Good" else echo "Failure" fi #-------------------------- its always going to else part and printing... (8 Replies)
Discussion started by: ch33ry
8 Replies

4. UNIX for Advanced & Expert Users

script to check if file was downloaded

I want to create a script to check if a file was downloaded into a folder. if it was i dont want to re-download it. The requirement is as follows. The first time the file (filename: A) is downloaded, it is renamed by stripping off part of the filename to filename A22. The second time an... (1 Reply)
Discussion started by: wizardofoz
1 Replies

5. Shell Programming and Scripting

How to check file permissions from a script.

hello, I have to write a script to run the other script inside it.So iam planning to write like this? first check the perimissions of the file. Alogorthim ---------- if(!filepermissions == execute) then echo" Permissions denined" else execute the script. file name is : load_mf.sh... (1 Reply)
Discussion started by: rajkumar_g
1 Replies

6. UNIX for Advanced & Expert Users

Check EOF char in Unix. OR To check file has been received completely from a remote system

Advance Thanks. (1) I would like to know any unix/Linux command to check EOF char in a file. (2) Or Any way I can check a file has been reached completely at machine B from machine A. Note that machine A ftp/scp the file to machine B at unknown time. (5 Replies)
Discussion started by: alexalex1
5 Replies

7. Shell Programming and Scripting

script to check if another script is running and if so, then sleep for sometime and check again

Hi, I am a unix newbie. I need to write a script to check wheteher another script is still running. If it is, then sleep for 30m and then check again if the script is running. If the script has stopped running then, I need to come out of the loop. I am using RHEL 5.2 (2 Replies)
Discussion started by: mathews
2 Replies

8. Shell Programming and Scripting

Script to check if file exists

guys, I am trying to write a script that does the following: it looks for a file in a specific directory and if the file is not there (NOT), it emails me. I have tried the following but its not working. It simply hangs up. Please help. if then mail -s 'blah blah blah' my email... (4 Replies)
Discussion started by: basisvasis
4 Replies

9. Shell Programming and Scripting

File check script

Hi, This script may be basic for expert, How to monitor files on a special folder (ls -rtla) and output the result to a file with timestamp name ? I'll schedule the script with Cron. Thanks, Fabien (5 Replies)
Discussion started by: unclefab
5 Replies

10. Shell Programming and Scripting

Script to check file sequence

Hi everyone, I need help in creating a script that would check if the file sequence is in order in a particular directory. These are log files that are generated throughout the day. Example of the file name will be, ABC01_YYMMDDHHMM###### (ABC01_0904161829000001) Sometimes the file... (4 Replies)
Discussion started by: kumaran21
4 Replies
Login or Register to Ask a Question