The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File Modified : Alert me StrengthThaDon UNIX for Dummies Questions & Answers 6 04-08-2008 04:23 PM
perl find directory only if modified in last hour frustrated1 Shell Programming and Scripting 0 10-12-2007 05:50 PM
an hour less in 24 hour system bobo UNIX for Dummies Questions & Answers 3 10-23-2006 12:55 PM
What resides on my server(s) keith.m UNIX for Dummies Questions & Answers 0 07-18-2006 03:03 PM
ALERT!!! ALERT!!! I messed up the UNIX!!! Fwurm UNIX for Dummies Questions & Answers 15 11-06-2001 05:53 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-03-2007
yazhini.t yazhini.t is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 1
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 (permalink)  
Old 12-03-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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 (permalink)  
Old 12-03-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,411
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

Closed Thread

Bookmarks

Tags
perl, perl shift, shift, shift perl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0