How to pick only the files which are generated in one hour? | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

How to pick only the files which are generated in one hour?

Shell Programming and Scripting


Tags
copy, hourly, pick, specific time frame., time frame

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-11-2013
akore83 akore83 is offline
Registered User
 
Join Date: Feb 2013
Last Activity: 13 February 2013, 1:59 AM EST
Location: India
Posts: 3
Thanks: 3
Thanked 0 Times in 0 Posts
Linux How to pick only the files which are generated in one hour?

Hello Masters,
I need one help.
I want to copy the files which are continuously generating on one server.
But this would be on hourly basis.

e.g.

Code:
-rw-rw-r-- 1 akore akore 0 Feb 12 03:20 test1.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 03:42 test2.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 04:22 test3.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 04:50 test4.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 05:22 test5.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 05:42 test6.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 06:55 test7.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 06:58 test8.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 07:17 test9.log 
-rw-rw-r-- 1 akore akore 0 Feb 12 07:28 test10.log

From above first I need to copy the files which are generated between Feb 12 03:00 to Feb 12 03:59.

Code:
Then Feb 12 04:00 to Feb 12 04:59
Then Feb 12 05:00 to Feb 12 05:59

and so on.

That means in 24 hrs my script will copy 24 times.
I need this on daily basis.
I will set a cronjob for this.
But not sure how to pick.
Please help me over here so I can copy the files on ourly basis.
Thanks in advance

Last edited by Scrutinizer; 02-11-2013 at 08:17 AM.. Reason: code tags
Sponsored Links
    #2  
Old 02-11-2013
bdittmar bdittmar is offline
Registered User
 
Join Date: Mar 2008
Last Activity: 15 November 2013, 9:55 AM EST
Location: Germany
Posts: 67
Thanks: 2
Thanked 4 Times in 4 Posts
find and copy

Hello,

use find with time options (-mtime, -ctime, -atime, -cmin ....)
and -exec cp in your cron.
The Following User Says Thank You to bdittmar For This Useful Post:
akore83 (02-11-2013)
Sponsored Links
    #3  
Old 02-11-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 4 April 2014, 4:57 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,359
Thanks: 8
Thanked 534 Times in 513 Posts
Touch two files with the right times and "find ... -type f -newer low_time ! -newer high_time"?
The Following User Says Thank You to DGPickett For This Useful Post:
akore83 (02-12-2013)
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to tail real time file Generated every hour? ooilinlove Shell Programming and Scripting 7 04-30-2012 04:27 AM
Files generated today kusathy Shell Programming and Scripting 3 12-30-2011 06:57 AM
core files not getting generated asalman.qazi Solaris 4 11-23-2009 09:10 AM
Type v for generated files shubhranshu UNIX for Advanced & Expert Users 2 05-06-2009 03:54 AM
Ftp all the generated files im_new Shell Programming and Scripting 3 12-22-2007 05:46 AM



All times are GMT -4. The time now is 03:12 PM.