find files onder than 15 minutes

Hi Friends,

i have to write a script to raise a flag if there are any files that are older than 15 minutes in the directory.The directory is supplied as the parameter to the script.
please help with a sample script.

Thanks in advance
veera

Please read the rules:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

I have closed the duplicate thread.

This is cheesy, but meets the requirements (the right way would be to touch the file back 15 minutes)

#!/bin/bash

RCPT="username@domain.zzz" # This is who to mail the list to

touch /tmp/.adkojha

if [ "$1" = "" ]
   then echo "Usage: $0 /path/to/dir"
          exit 1
fi
cd $1

sleep 900
find . -newer /tmp/.adkojha | mail $RCPT
rm -f /tmp/.adkojha

Sorry it has been a long day

A question. Why use a touch and then a rm.

find has -amin and -mmin option. That can be used as well.

Is there any reason as such, that these do not serve the purpose ?

Vino

Hi Friends,

Thanks a lot for your response.yes i can always use find with amin and mmin.

And the reply given by 98 1 LE is also helpful.
Once again thank you friends
Bye
veera

vino, amin and mmin are not standard. GNU added them to their version of find which Linux uses. They will not work with the standard find command.

Perderabo,
Thanks much.

vino

Hi friends,

Thanks for your reponses .But let me put forth my clearly what i am trying to do.
I need to check a directory for some .sql files from the script.
From this shell script i am executing all the .sqls.
But if there are any .sqls older than 15 minutes then a flag should be raised.
If there are any .sqls less than 15 minutes old then they have to be processed as usual.

Please help.
Thanks in advance
Veera

is this a standard compliant?, Perberado, correct me if not.

(this shows only files which have not been modified in the last 15 minutes, you can use -15m insted of the '+' to see what files have been changed in the last 15m)

$ find . -mtime +15m -print

I learned something new today. Thanks :slight_smile:

EDIT: It does not seem to work using the standard Solaris 9 find:

/tmp/a > ls -l
total 0
-rw-r--r--   1 chuck   sysadmin       0 Aug 10 18:23 file
-rw-r--r--   1 chuck   sysadmin       0 Aug  8 17:11 fileb
/tmp/a > find . -mtime +15m
/tmp/a > find . -mtime -15m
.
./fileb
./file

Hi Friends,

Thanks a lot to all of you for your suggestions. i used them on Solaris system and they are working .But the same switches are not working on a
HP-UX system.
Is there any option that i have to use on a HP-UX System ?

I need to raise a flag if there are any files older than 15 minutes in a directory.

Please help.
Thanks in advance
Veera

Hi Friends,

I couldnt get any option on HP-UX for finding files older than 15 minutes.
but the solutions that i got from you friends worked on Solaris and Linux.
So i am using a c executable file for getting the age of a file and then raising a flag if it is older than 15 minutes.

Thanks for all your help
Bye
Veera