Solved

How to move files that are older than 2 days

Posted on 2004-03-23
4
332 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 250 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

617 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