- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to move old files
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
09-01-2011 11:32 PM
09-01-2011 11:32 PM
Script to move old files
I am not too familiar with script , if I want to do the housekeeping in a path as below , can advise what can I do ? Thanks
1) move the files ( /tmp ) elder than 90 days to a specfic path ( /tmp/bak )
2) remove the files elder than 180 days and gzip these remove files in /tmp/bak .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2011 03:25 AM - edited 09-02-2011 03:31 PM
09-02-2011 03:25 AM - edited 09-02-2011 03:31 PM
Re: Script to move old files
Take a search the category for previous topics that are similar.
>1) move the files (/tmp) older than 90 days to a specific path (/tmp/bak)
find /tmp -mtime +90 -exec mv {} /tmp/bak \;
(If you want to use "-exec ... +, you'll need to write a script that reverse the parms to mv(1).)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2011 12:48 AM
09-05-2011 12:48 AM
Re: Script to move old files
Thx reply,
The command you provided is for request 1 , can advise if I would like to do the thing as point 2 , what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2011 05:14 AM - edited 09-05-2011 05:17 AM
09-05-2011 05:14 AM - edited 09-05-2011 05:17 AM
Re: Script to move old files
>The command you provided is for request 1, can advise if I would like to do the thing as point 2, what can I do?
The idea was that you would figure 2) out from the solution to 1).
find /tmp -mtime +180 -type f | while read filename; do
gzip -c "$file" > "/tmp/bak/$file.gz"
if [ $? -eq 0 ]; then
rm -f "$file"
else
echo "Problem gzipping $file" 1>&2
fi
done
If /tmp has subdirectories, there'll be problems.