![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to find files older than 2 hours | pt14 | AIX | 3 | 03-05-2008 08:31 AM |
| how to find files older than 4hours in HP-UX | caprikar | UNIX for Advanced & Expert Users | 3 | 11-27-2007 01:23 PM |
| find files older than a given file | Shivdatta | Shell Programming and Scripting | 5 | 07-24-2006 04:25 AM |
| only find files older than x minutes old | dsimpg1 | Shell Programming and Scripting | 1 | 05-18-2006 08:48 PM |
| Find files older than 20 days & not use find | halo98 | Shell Programming and Scripting | 2 | 05-18-2006 11:19 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
find files older than 30mins,count and send mail
Hi all,
I wrote this script to find files older than time parameter, count the number of files, and send an email to me that some files are in a particular folder. For the particular path, the script should wait delay parameter before running again. For example, assuming the input file looks like this 20 A/B/ 5m 10 C/D 4m The script changes dir to A/B, finds all files older than 20mins,counts them and sends an email to me.It then waits 5minutes before running again.It, however,keeps running to process the second path (C/D). It only waits if it found files older than the time parameter, otherwise it does nothing.It waits only for the path if found files, otherwise it keeps processing other paths. I wrote something like this but doesnt seem to work Code:
#!/bin/ksh
#The filepathinput format is 30 /A/B/C/gunner 10m
while read AGE PATH DELAY
do
cd $PATH
for file in $(ls)
do [[ $(( $(./fileage $file)/60)) -ge $AGE ]]
echo $file >>outputfiles.txt
done
final=`wc -l outputfiles.txt|awk '{print $1}'`
if $final -ge 1
then
echo $final|mailx -s "Unprocessed Files in blabla" gunner.love@henry.com
else
echo "Everything's OK"
fi
rm -f outputfiles.txt
sleep $DELAY
cd -
done < filepathinput.txt
Thank you |
| Forum Sponsor | ||
|
|
|
|||
|
followup
Hi,
I ran the scriipt but got these errors. I checked the ksh path and its in bin/ksh and usr/bin/ksh. Code:
sh -x trymonitor.sh
+ 0< filepathinput.txt
+ read AGE PATH DELAY
+ cd /A/B/C/
+ 1> outputfiles.txt
+ ls
trymonitor.sh[12]: ls: not found.
+ + awk {print $1}
+ wc -l outputfiles.txt
trymonitor.sh[14]: awk: not found.
trymonitor.sh[14]: wc: not found.
final=
+ [ -ge 1]
trymonitor.sh[15]: test: A ] character is missing.
+ echo Everything's OK
Everything's OK
+ rm -f outputfiles.txt
trymonitor.sh[21]: rm: not found.
+ sleep 10m
trymonitor.sh[22]: sleep: not found.
+ cd -
|