Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-17
4
Medium Priority
?
449 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 1500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 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