How can i search a file which has been created or modified in last five minutes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How can i search a file which has been created or modified in last five minutes
# 1  
Old 08-07-2008
Error How can i search a file which has been created or modified in last five minutes

Hi
Can some one please help me
How can i search a file which has been created or modified in last five minutes
I have used the command

find . -mmin -5

and it does not work
i get an error -mmin is bad option

Please help
Much regards
Tarun
# 2  
Old 08-07-2008
Code:
#!/bin/ksh
# filetimes
filetime()
{
    perl  -e '
          $mtime = (stat $ARGV[0])[9];
          print $mtime
         ' $1
}
now=$(date +%s)
limit=$(( $now - 300 ))  # 5 minutes ago

find /path/to/files -type f |\
while read filename 
do
	dt=$(filetime  $filename)
	if [[ $dt -lt $limit ]] ; then
   		ls -l $filename # do whatever you want here
   	fi
done

# 3  
Old 08-07-2008
Did you try this
Code:
find . -mmin -5

- nilesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

rsync a file as it gets created and after 3 minutes old

- run a backup job - The jobs creates partial files one after the other, about 2 minutes interval. What i want to do is that while the job is still running or while a file was last modified or created 3 minutes ago, the file should be rsync to a remote server untill the last file has been... (4 Replies)
Discussion started by: malaika
4 Replies

2. UNIX for Beginners Questions & Answers

Find if create time of last created file in a directory is older than 5 minutes

A process xyz is running and creating file1, file2, file3, .... filen. how do i know if the process has stopped and createtime of the last file (filen) is older than 5 minutes? OS is AIX (3 Replies)
Discussion started by: malaika
3 Replies

3. Shell Programming and Scripting

How to send a file in UNIX through email which is created only 15 minutes before the current time?

I wanted to send an email to the client whenever there is failed record created in a /feed/HR-76/failed folder after processing of feed file. I can find out with the help of below script that what is the new file created but that file didn't make just 15 minutes before. ... (1 Reply)
Discussion started by: puneetkhullar
1 Replies

4. Shell Programming and Scripting

Script to search for a pattern in 30 minutes from a log file

Hello All, I have to write a script which will search for diffrent patterns like "Struck" "Out of Memory" , etc from a log file in Linux box's. Now I will be executing a cron job to find out the results by executing the script once in every 30 minutes. suppose time is 14-04-29:05:31:09 So I... (3 Replies)
Discussion started by: Shubhasis Mathr
3 Replies

5. Shell Programming and Scripting

Check how many minutes ago the last file created

Hi , I need help in getting how many minutes ago the last file, matching some pattern in file name, was created in a folder. Thanks in advance. (8 Replies)
Discussion started by: Anupam_Halder
8 Replies

6. Shell Programming and Scripting

Ftp get files created in last 30 minutes

Is it possible in an ftp script to get remote files based on whether they have been created in the last 30 minutes? (5 Replies)
Discussion started by: gefa
5 Replies

7. UNIX for Advanced & Expert Users

find files modified by hours instead of minutes

Is there an easy way to find files modified by hours? If you wanted to find something modified by like 28 hours then I know you could do this: find . -mmin -1440It is pain to break out a calculator and calculate in minutes. Could you do something similar to this? I know I don't have the right... (1 Reply)
Discussion started by: cokedude
1 Replies

8. Shell Programming and Scripting

search last modified file and process it

Hello, trying to build a shell script that - searches in defined location for similar files (eg. containing pattern in file name) - Identifies last modified - stores name in variable for processing Thanks a lot (4 Replies)
Discussion started by: alice07
4 Replies

9. Shell Programming and Scripting

find files created within 30 minutes

find . -name *.txt -mmin -30 This is working in Redhat but not in Solaris.. What is the equivalent option in Solaris? (1 Reply)
Discussion started by: tene
1 Replies

10. Shell Programming and Scripting

Find the directory modified/created before 4 days

Hi, I have an application which creates some directories while running. I want to delete these directories which are 4 days older. i tried find . type d -mtime +1 -print And it is working fine.. but find . type d -mtime +4 -print is not giving any results which are 4 days... (6 Replies)
Discussion started by: Tuxidow
6 Replies
Login or Register to Ask a Question