Solved

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

Posted on 2010-11-17
4
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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