![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| Date Calculations | mitschcg | UNIX for Dummies Questions & Answers | 8 | 03-06-2009 04:40 AM |
| Time Calculations & Conversions | Nysif Steve | UNIX for Advanced & Expert Users | 1 | 09-14-2007 12:07 PM |
| Time Calculations | Nysif Steve | UNIX for Dummies Questions & Answers | 5 | 09-14-2007 09:49 AM |
| Time difference calculations | satnamx | Shell Programming and Scripting | 1 | 07-26-2006 08:44 AM |
| Float calculations | sharmavr | UNIX for Dummies Questions & Answers | 1 | 07-26-2006 03:18 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem doing the time calculations in shell.
I am trying to do a shell script to monitor if any files went through in the last hour. There is a script in cron that runs every sec checking to see if a file is there and ftp the file out of this folder. Now I just want to add a block of code that will check to see no files went in the last hour send an email. ftp----------> folder to monitor ----------->ftp This is what i came up with so far. I am getting a little problem calculating the time. If someone could help me out here please. Code: Code:
#Set the path to the folder to monitor
SUBJECT="DWH FILES WERE NOT SENT IN THE LAST HOUR"
FILE1="/home/tibco/javastuff/test/dwh*"
cd /home/tibco/javastuff/test/
###### Run list command
ls -l
time=`echo $line | awk '{ split($8,a,":"); print (a[1]*60)+a[2] }'`
FILEMATCH=`echo $line | awk '{ print $9 }'`
if [ $FILE1 = $FILEMATCH ]
then
echo "$time" > dwhtime.txt
else
######## Run date command ##########
date
time2=`echo $line | awk '{ split($4,a,":"); print (a[1]*60)+a[2] }'`
if [ $time2 -gt $time ]
then
mail -s "$SUBJECT" testemail <<EOF
$SUBJECT
$time
EOF
fi
fi
|
|
||||
|
thats a good idea i will do that. Abou tthe time calcuations, do you have any idea how i should do this
In the code i am taking the time used in the ls -l command for that file and I am writing the time to a file, so when another file comes through it will overwrite the old time. So my issue is when no files comes for an hour I want it send an email So would it be $time2 - $time1 = $b if $b is greater than 60 mins then send email How would i do this part? |
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|