HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- move history file to another directory
Operating System - HP-UX
1825805
Members
2268
Online
109687
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
04-28-2004 02:52 PM
04-28-2004 02:52 PM
move history file to another directory
Hi,
I am newbie in unix/linux command. I have a system that every day always generate file on directory /mysystem/history. I want to create automatically job that can move files on directory /mysystem/history that created 7 days ago to directory /mysystem/oldhistory.
But i dont know how to do that. Any one can help me ?
I am newbie in unix/linux command. I have a system that every day always generate file on directory /mysystem/history. I want to create automatically job that can move files on directory /mysystem/history that created 7 days ago to directory /mysystem/oldhistory.
But i dont know how to do that. Any one can help me ?
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 02:55 PM
04-28-2004 02:55 PM
Re: move history file to another directory
You would need to write a script that utilizes the 'find' command to search for files within a directory and then takes action on those files.
# man find
for more details.
Now if you want this script to run automatically you will need to set it up in cron.
# man cron
# man crontab
for more details.
Have a read thru the man pages (they are a system administrators best friend!) and post back if you still have questions.
# man find
for more details.
Now if you want this script to run automatically you will need to set it up in cron.
# man cron
# man crontab
for more details.
Have a read thru the man pages (they are a system administrators best friend!) and post back if you still have questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 03:14 PM
04-28-2004 03:14 PM
Re: move history file to another directory
Hi,
Put this line as a shell script and run by cron everyday. This script move files which is older than 7 days from /mysystem/history directory to /tmp/history directory.
#find /mysystem/history -type f -mtime +7 -exec /usr/bin/mv {} /tmp/history \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2004 07:34 PM
04-28-2004 07:34 PM
Re: move history file to another directory
Create Shell script for e.g. myscript with following commands:
#!/usr/bin/sh
touch /mysystem/oldhistory
cat /mysystem/history >> /mysystem/oldhistory
> /mysystem/history
Make the script executable using
#chmod +x myscript
Then edit crontab file:
# crontab -e
insert entry as follows:
1 1 * * 5
Save it
This will execute the sript every Friday at 1 hour 1 min.
You can change the execution as per your convenience by changing first two field ( 1st Min .. 2nd Hour )
Hope this should work for you
#!/usr/bin/sh
touch /mysystem/oldhistory
cat /mysystem/history >> /mysystem/oldhistory
> /mysystem/history
Make the script executable using
#chmod +x myscript
Then edit crontab file:
# crontab -e
insert entry as follows:
1 1 * * 5
Save it
This will execute the sript every Friday at 1 hour 1 min.
You can change the execution as per your convenience by changing first two field ( 1st Min .. 2nd Hour )
Hope this should work for you
You need to know a lot to actually know how little you know
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP