Solved

How to find and move the files based on time stamp in Linux system?

Posted on 2010-11-17
4
442 Views
Last Modified: 2012-05-10
This is SUSE Linux enterprise server 11.0. This is a folder, called WHETHER, used to collect latest info about the whether. Newer files would be updated anytime. To avoid the file and folder sizes outgrown, I'm thinking to move the files, that are more than 1 month old, to another backup folder - /backup/Whether. How should I do it to use a cron job?
0
Comment
Question by:Balack
  • 3
4 Comments
 
LVL 23

Expert Comment

by:savone
ID: 34161391
find /WHETHER -mtime +90 -exec mv '{}' /backup/Whether \;
0
 
LVL 23

Expert Comment

by:savone
ID: 34161395
sorry this is probably better:

find /WHETHER -type f -mtime +90 -exec mv '{}' /backup/Whether \;
0
 
LVL 23

Accepted Solution

by:
savone earned 500 total points
ID: 34161404
You can add it to cron like this:

crontab -e

then add this line:
# run five minutes after midnight, every day
5 0 * * * find /WHETHER -type f -mtime +90 -exec mv '{}' /backup/Whether \;

I am not sure where your WHETHER folder is, this assumes its at the root of the filesystem.  If its somewhere else you might want to change the \WHETHER to your path
0
 

Author Closing Comment

by:Balack
ID: 34264071
Good
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now