To check the lists of file created between 30-60 min


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To check the lists of file created between 30-60 min
# 1  
Old 07-15-2008
To check the lists of file created between 30-60 min

Hi

I have to write a script, that will find out the lists of files in a particular directory, which are created between 30-60 min intervals.
# 2  
Old 07-15-2008
use touch to create two files - one 30 minutes old and the other 60 minutes old.
Then use find with the -newer option
Code:
touch -t 200807152100 min30
touch -t 200807152130 min60
find /path/to/files -type f \( -newer min60 -a ! -newer min30 \)

# 3  
Old 07-15-2008
The files are created by script, i cannot manually create the file.this script will be running after every 1 hr, so i cannot hardcode the time inthe script.
# 4  
Old 07-15-2008
Here I have a perl script that does what you exactly want. As agrument pass the path you want to search for files:

use strict;
use File::Find;

my $path_to_start = $ARGV[0];
my @files_bet_30_60 = ();
my $thirty_mins_in_secs = 30*60;
my $sixty_mins_in_secs = 60*60;

finddepth(\&wanted, $path_to_start);
foreach my $file (@files_bet_30_60) {
print "$file\n";
}

sub wanted {
my $file = $File::Find::name;
next unless (-f $file);

my $mtime = (stat($file))[9];
my $time_diff = time - $mtime;
push @files_bet_30_60, $file if
(($time_diff > $thirty_mins_in_secs) && ($time_diff < $sixty_mins_in_secs));
}

Regards,
Visit my blog: techdiary-viki.blogspot.com
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to check current date file is created and with >0 kb or not for multiple directories

Hi All, I am new in scripting and working in a project where we have RSyslog servers over CentOS v7 and more than 200 network devices are sending logs to each RSyslog servers. For each network devices individual folders create on the name of the each network devices IP addresses.The main... (7 Replies)
Discussion started by: Pinaki
7 Replies

2. Shell Programming and Scripting

Check if file got created in less than 10 hrs

Dear Gurus, I want to check if file got created in less than 10 hrs in .ksh. Here is my requirement In $var5 : I'm storing file name In $var4 I have stored : select to_char(sysdate,'YYYYMMDDHH:MM:SS') from dual; If that file date time is less than 10 hrs, then I need to check if less... (1 Reply)
Discussion started by: thummi9090
1 Replies

3. Shell Programming and Scripting

Help to check uptime post 30 min or so after every reboot

Hi, Please help me to cross verify the post reboot time. I want to execute some script after every reboot, which will happen only post 20-30 mins of reboot. If uptime is >24hrs, script should not execute. I tried with below command, but seems no luck. >> uptime | sed 's/^.*up//' | awk -F,... (1 Reply)
Discussion started by: KailasB
1 Replies

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

5. Shell Programming and Scripting

How to check the status of script for every 5 min?

Hi, Can any1 provide the code for my req: I am loading few set of files into database through one unix script. I ll try to describe the process: load_cdr-->main script Source Feeds are A & B. File in A-akm.dat File in B-bkm.dat Now my script runs through cron jobs everyday...and for both... (6 Replies)
Discussion started by: gnnsprapa
6 Replies

6. UNIX for Dummies Questions & Answers

Check number of files that were created before a date?

Hi all, In a directory I have a lot of files created in history. However do I check the number of files that were created before a designated date? Thanks (1 Reply)
Discussion started by: isaacniu
1 Replies

7. Shell Programming and Scripting

check file exists and created today issue

Morning My other issue I have seems very simple but im just not seeing it. I have a script that checks on a remote share to see if the backups for some systems have run. Its as simple as: find /mnt/ukwcs-net-config/WLAN-Controllers/ -mtime -1 -ls | egrep '(cfg)' > wlanlog.txt cut -c 1-92... (4 Replies)
Discussion started by: ltodd2
4 Replies

8. Shell Programming and Scripting

Check file created is less than 4 hours or not.

Hi, I need to check some files in one directory whether any files has been created before 4 hours(ie, less than 4 hours from the current time). Can anybody help me out..? Thanks in advance..! (21 Replies)
Discussion started by: Kattoor
21 Replies

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

10. Shell Programming and Scripting

Check lists for Unix Shell Programming

Hi all, Can anyone provide me any checklists or a list of steps I should follow before executing my scripts. Could also tell me if there are any other standards to be followed while shell programming like naming conventions for variables etc. Your help would be much appreciated. Regards,... (2 Replies)
Discussion started by: srikanth_ksv
2 Replies
Login or Register to Ask a Question