Find files created on weekend,monthend,quarteley etc
Hi ALL
I have 365 files created in a folder on daily basis.. its a daily cron created for the backup. Now i would like to group the files created in end of week ,end of month etc in to a seperate folder . can any one help me to to find the files using 'find' command to extract those files Thanks Sujith |
For what I know you can only find your files based on the modification time and not on the creation time. At least not with linux e*fs. I'm not sure with other filesystems though. Still there are other possible ways to find the files. Some of these are by:
(a) depending on the average time a backup process goes - if it's just quick, you can base it from the modification time (b) the filename of the file - are there dates added to the file? (c) or the contents of the files - If dates are included inside the files, maybe the first lines can help |
Is there a naming convention for the file names which includes the date somehow?
|
Yaa each days backup ended with time stamp like "20080313.tar.gz"
i need to get the find or xargs command syntax for listing files created on 7 th day of weeks last day of month etc.. Quote:
|
for each 7th day of the month do you mean something like this:
Code:
year=2008 You can use time(), date(), mktime() and strtotime() in php but i don't know how to do that in perl. You can use the external command date but only for only the current time or else you'll have to go alternating your clock and that won't be good. |
Well, xargs is not suitable here, but you can read the output of find into a while loop, and perform some operations on each file to determine which ones you want to handle.
Please provide examples of full file names. |
Here's an example shell script which will identify files from the end of week and end of month. Note that a date can be BOTH at the end of the week, AND at the end of the month. When you modify this script to do something with the files, make sure you take that into account.
Code:
#!/bin/bash Save this into a file called myscript.sh, chmod 755 that file, and run it using the full path, and pass the names of files to process as parameters, e.g. if you create the file in your HOME directory, called myscript.sh: Code:
chmod 755 ~/myscript |
Code:
is_end_of_month () { http://www.theregister.co.uk/2008/02...ttack_ballmer/ |
Quote:
|
Hi
The full file name is like mysqldump_20080309.tar.gz mysqldump_20080310.tar.gz mysqldump_20080311.tar.gz mysqldump_20080311.tar.gz mysqldump_20080313.tar.gz I need to move the above files into another folder ie created on each weekends (sunday),end day of month etc.. ie for segrating weekend backups,monthly backup etc Thanks Sujith Quote:
|
OK, I can't help myself.
Change the functions like this: Code:
is_end_of_month () { |
Quote:
I'm constantly amazed how some things that seem they should be easy in fact cause great difficulty. Different countries had adopted the Gregorian calendar during different years. Different states in the US on different dates as well. If you have a database that records historic events, that needs to be taken into account. Have you ever heard of leap-seconds? Due to tidal forces, the rotation of the earth slows down over time. Every few years a second is added before the New Year. However, there are two dates in the year when might be added. And the US wants to not do this for the standard atomic clock. I think the argument is to count the seconds from the base time and let the clients do the adjusting. Funny thing is since 2000, the earth's has started rotating faster! No one knows why. ( At least according to the Wikipedia article on Leap Seconds ) I applied the updates last month and one of them was for a 30 minute adjustment for the time in Venezuela. Their dictator is obviously the center of the Universe! It reminded me of the movie "Banana's" where it was declared that underwear should be worn on the outside of the pants. As I understand it, there is only one timezone in all of China! I wonder if it is called "CPCT"? |
Quote:
|
I see this as a classroom assignment for use of 'date' command. For details see 'info date'. Putting everything inside 'find' is just classroom sadism.
Code:
#!/bin/bash |
Quote:
|
All times are GMT -5. The time now is 11:32 PM. |