Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to move files that are older than 2 days

Posted on 2004-03-23
4
Medium Priority
?
338 Views
Last Modified: 2013-12-15
Does anybody know how to modify a script i run to grab all files older than 2 days?

Here is my current code

mv -f -u /mnt/test/* /mnt/test2 || mail -s "Scotts move has failed" scotts@cms-email.com < /dev/null

And I don't think that tmpwatch is the answer
0
Comment
Question by:shasta247
[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
  • 2
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
jlevie earned 1000 total points
ID: 10662520
cd /mnt/test
find . -ctime +2 -exec mv {} test2 \;
0
 
LVL 1

Author Comment

by:shasta247
ID: 10669280
Excellent - thanks jlevie!
0
 
LVL 1

Author Comment

by:shasta247
ID: 10669283
do you know how to make the script email me if it doesn't find anything?
0
 
LVL 40

Expert Comment

by:jlevie
ID: 10669864
I assume you mean if there weren't any files older than 2 days in /mnt/test. The shell script below should do that:

#!/bin/sh
cd /mnt/test
cnt=`find . -ctime +2 | wc -l`
if [ $cnt -gt 0 ]; then
  find . -ctime +2 -exec mv {} ../test2 \;
else
  echo "No files found older than 2 days" | mail -s "Scotts move has failed" scotts@cms-email.com
fi
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

722 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