If any file resides for more than an hour in this directory then to raise an alert


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting If any file resides for more than an hour in this directory then to raise an alert
# 1  
Old 12-03-2007
If any file resides for more than an hour in this directory then to raise an alert

Hi
If there is a file upload done from a remote server
and if the file remains without being extracted for more than an hour,
I need to identify the files and create an alert message to the
users in the other end.
please help me writing a shell script for it.

Regards
Yazhini
# 2  
Old 12-03-2007
You'll need to come up with your own way of determining if it's been extracted or not (or provide more details as to what changes in the file or filename).

I can help with some pseudo code for the rest though:
Code:
period=300 # 5 mins
threshold=3600 # 1 hour
now=`date +%Y%m%d%H%M%S`
while true
do
  for file in <your test for the presence of unprocessed files>
  do
    difference=$now - `<get $file mtime>`
    if [ $difference -ge $threshold ]
    then
      <raise an alarm for $file being $difference old>
    fi
  done
done

# 3  
Old 12-03-2007
If you have perl, this script will find all files not modified in the last hour...
Code:
#!/usr/bin/ksh

function file_hours {
    perl -e 'printf "%i\n", 24*(-M shift);' -- $1
}

cd wherever

for file in *
do
    if [[ $(file_hours $file) -ge 1 ]]
    then
        echo $file is old
    else
        echo $file is new
    fi
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alert for missing file in directory

Deleting code (6 Replies)
Discussion started by: Adfire
6 Replies

2. Shell Programming and Scripting

How to execute a shell script that resides in another server?

hi, i have a shellscipt that is in another server, my question is how do i run the script from a different server. EXAMPLE: SCRIPT_NAME: sample.sh SERVER: A what i wanted to achieve is to call that script from server B. Tried using ssh ssh <username>@serverB /home/sample.sh but... (5 Replies)
Discussion started by: reignangel2003
5 Replies

3. AIX

Command to check on which vg filesystem resides

Hi, I need to know on which volume group filesystem resides. TIA (5 Replies)
Discussion started by: sumanthupar
5 Replies

4. Shell Programming and Scripting

How to convert 24 hour time to 12 hour timing?

Hi friends, I want to convert 24 hour timing to 12 hour please help me... my data file looks like this.. 13-Nov-2011 13:27:36 15.32044 72.68502 13-Nov-2011 12:08:31 15.31291 72.69807 16-Nov-2011 01:16:54 15.30844 72.74028 15-Nov-2011 20:09:25 15.35096 ... (13 Replies)
Discussion started by: nex_asp
13 Replies

5. Shell Programming and Scripting

Script to Change Permission on a directory after every hour

I want to change the permission of a dir to 777 after every hour in a background process.I do not have the access to the crontab , is there another way of doing it a scrit of some thing like that . Any help will be great. (1 Reply)
Discussion started by: neeraj617
1 Replies

6. Shell Programming and Scripting

Script to send an alert if a file is present in a directory for 10 min

hi, A script which look into a directory and send an alert via a mail. If there is any file exisiting in a directory for more then 10 min. (5 Replies)
Discussion started by: madfox
5 Replies

7. Shell Programming and Scripting

raise an alarm in Unix

Hi members, I am working in WebSphere in Unix environment. we are working with 500 odd servers and most of the times processes got down. Can i have any shell script through whih some popup with alarm get raised whenever some server get down. kindly help.. Thanks Rishi (1 Reply)
Discussion started by: rishi.madan
1 Replies

8. Shell Programming and Scripting

Script to raise the alarm in the log File

Hi All, Please help to write the script that should raise an alarm if the new logs will not come in the log file. In other words i want to write a script which will monitor the log file continuously and will raise an alarm if the logs will not come after some time suppose 5... (5 Replies)
Discussion started by: akhtar.bhat
5 Replies

9. Shell Programming and Scripting

perl find directory only if modified in last hour

I want a one liner perl command to find a directory only if the modified time is within the last hour I am running this on windows - and I will define a variable for the result. So for example I want to return value of 1 for the variable if the modified time of d:\test1 is within the last... (0 Replies)
Discussion started by: frustrated1
0 Replies

10. UNIX for Dummies Questions & Answers

What resides on my server(s)

I've got several AIX 5.3 LPARS that I'm administering, set up by 3rd party vendor before I got here. I've been asked by management to report on what's on each server; software, versions, patches available, etc. I know they're not identical: I've got different versions of ORACLE, APACHE, JAVA,... (0 Replies)
Discussion started by: keith.m
0 Replies
Login or Register to Ask a Question