Run a script if file modified in last 10 min


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Run a script if file modified in last 10 min
# 1  
Old 01-06-2010
Run a script if file modified in last 10 min

Hi,
I want to check if a file is modified or not in the last 10 mins and run a script if so. Thanks
# 2  
Old 01-06-2010
We need more detail, please.
# 3  
Old 01-06-2010
sounds like a nice programming exercise for perl, using the localtime() and stat() functions, primarily.
# 4  
Old 01-07-2010
Hi,
File has alarms so if an alarm occurs, file will be updated. I just want to check if a file is modified in last 10 mins or not and run some script if it is modified. Thanks.
# 5  
Old 01-07-2010
Check if this helps

Code:
 if [ `find . -mmin 5` ]; 
then 
echo "exec the script";
 else 
 echo "donot exec the script";
 fi

change the mmin to the value you want and replace with the scripts to execute

or you can use
Code:
 
for i in `find . -mmin -10`; do  echo "exec the script"; done

HTH,
PL
# 6  
Old 01-07-2010
Code:
find . -mmin -10 -exec 'script' \;

If specific file,

Code:
find -iname 'FILENAME' -mmin -10 -exec 'script' \;

# 7  
Old 01-07-2010
Quote:
Originally Posted by thegeek
Code:
find . -mmin -10 -exec 'script' \;

If specific file,

Code:
find -iname 'FILENAME' -mmin -10 -exec 'script' \;

Nice , only one slight modification for optimization Smilie
Code:
find . -type f -mmin -10 -exec 'script' \;

Or

Code:
find -type f -iname 'FILENAME' -mmin -10 -exec 'script' \;

It has to be a regular file if it can be modified.
Cheers.
Regards.
Gaurav.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to run cron entry every 5 min during office hours only?

Hi I need to setuop a cron entry to run every 5 min, only in office hours (between 8:00AM to 18:00PM, I did the following: 0,5,10,15,20,25,30,35,40,45,50,55 8,9,10,11,12,13,14,15,16,17,18 * * * /home/xxx/zzz.ksh But somehow does not work. Could it be wrong? (8 Replies)
Discussion started by: fretagi
8 Replies

2. UNIX for Dummies Questions & Answers

Run a cronjob only when a file is modified?

Hello, I am new to cron. I have a cronjob that updates a dataset in a 3rd party application. The contents of this dataset come from a text file, which is updated irregularly. Currently my cronjob runs once every week, to update this dataset (irrespective of whether the file was updated or not).... (7 Replies)
Discussion started by: ad23
7 Replies

3. Shell Programming and Scripting

Script to FTP a modified file

Hello, I am fairly new to shell scripting. I see a lot of examples out there of how to find if a file has been modified within a certain period of time. What I'm looking for help with is a script that will run and I'm thinking check for the last 24 hours but if not just check at runtime to see... (6 Replies)
Discussion started by: PyroPlasm
6 Replies

4. Shell Programming and Scripting

Run a script when a file is modified/time stamp changed

Hi, I need to run a script file which uses a file and that file is modified as and when some alarms generated, it is not based on any fixed time period.. it may be modified even once in a minute for some time and once in 30 min or once in 20 min. Hence i need to watch for the timestamp change of... (3 Replies)
Discussion started by: aemunathan
3 Replies

5. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

6. Shell Programming and Scripting

Shell script: If a file stays in a particular directory more than 30 min send an email

Hi , I am new to shell scripting. i have a requirement say i will receive a file in a directory say /xyz.if that file stays in that directory more than 30 min i need to get a mail to my outlook.this should run for every 20 min in crontab. can anyone help me? (8 Replies)
Discussion started by: muraliinfy04
8 Replies

7. 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

8. UNIX for Dummies Questions & Answers

SFTP script - poll every min to check file complete before transfering

Hello, Before I do a GET remote file, I need to ensure the remote file is a complete file i.e. whatever process is saving the file to the remote folder should complete the transfer before I go GET it through my script. So I'm thinking I need to poll the remote file every minute or so to... (4 Replies)
Discussion started by: srineel
4 Replies

9. Shell Programming and Scripting

command to know files modified morethan 30 min

Hi, i use ksh and want to know the command for gettting the files which were not modified in last 30 min. find . -name <filename > -mtime 0.0209 is not giving the results. Thanks , Mohan (3 Replies)
Discussion started by: mohanpadamata
3 Replies

10. UNIX for Dummies Questions & Answers

how to retrieve original contents of a modified file (modified using vi)

Made changes to a file using vi editor and saved those changes now realised that the changes are not required How can I get the previous version of the file.i.e the one which was there on which I had made changes (3 Replies)
Discussion started by: novice100
3 Replies
Login or Register to Ask a Question