Solved

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

Posted on 2010-11-17
4
441 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

21 Experts available now in Live!

Get 1:1 Help Now