- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Move files older than 3 hours to archive directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 01:36 PM
06-12-2002 01:36 PM
Move files older than 3 hours to archive directory
I was wondering if there is an easy way to do this ... I need to move log files older than 3 hours to the archive directory, for now I've a written a script (runs every 4 hours in cron) to do that and works okay, but it is not very efficient.
Any help would be greatly appreciated.
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 01:41 PM
06-12-2002 01:41 PM
Re: Move files older than 3 hours to archive directory
Why do you not consider your approach efficient? Inherently, this has little overhead.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 01:42 PM
06-12-2002 01:42 PM
Re: Move files older than 3 hours to archive directory
You may consider using '-newer' option with find command. Touch a file and find the more recently modified files.
# man find (for details)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 01:56 PM
06-12-2002 01:56 PM
Re: Move files older than 3 hours to archive directory
It is good taht you already have a wokring solution . May be run it every 3 hrs instead of 4 hrs , use find with options or
ls -l | awk '{if ($9 > "x" ) print $NF }' print the o/p in a file and use that file as the input to move the files .
You can just increment the value of x by whenever you want to run it .
Manoj Srivastava
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 02:17 PM
06-12-2002 02:17 PM
Re: Move files older than 3 hours to archive directory
I can live with the current script but just curious if you guys had a similar requirement ..
Shiju,
I am aware of the newer file option with find ... and thought about using it, but settled for a different logic ...
Manoj,
I'll think about your option ...
Thanks Guys !
-Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2002 10:52 PM
06-12-2002 10:52 PM
Re: Move files older than 3 hours to archive directory
I made 2 script.
the first calculates the
time to minutes.
the second calculates it to
time again so it can be used
to by the touch command.
calculate the time in minutes
minus 180,
calculated this back to time,
touch a file with this time,
move all files that are not
newer then this file.
I use them for 40 minutes.
set $(min2date.sh $(expr $(date2min.sh) - 40))
touch -t $1$2$3$4 tempfile
the scripts do NOT work at the start of a new year.
The scripts are attached to
this message.
when you want, try it.
Regards Gregor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2002 05:57 AM
06-13-2002 05:57 AM
Re: Move files older than 3 hours to archive directory
In general, it is important to try not to use loops, or, if you have to use them, only/mainly use built-in shell commands in the loop, i.e. no external ones, i.e. not from /usr/bin, etc..
Apparently you are already aware of find(1) and its "-newer" option. I advise to use that and pipe the list of files to be mv(1)-ed to xargs(1), so xargs(1) can invoke mv(1) multiple files to be moved, instead of just a single one.