- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- removing a log file that is 5 days old or older
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
Discussions
Discussions
Discussions
Forums
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
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-21-2006 05:31 AM
тАО06-21-2006 05:31 AM
removing a log file that is 5 days old or older
I know you have been asked about this before.
HP-UX 11.11 and 11.23
We have old log files that need to be deleted that are older the 4 day old and would like to know the most automated way of doing this.
We will have this run as a crontab too so that part I do not need to know. We know in Linux you can do this but we are using HP-UX.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 05:36 AM
тАО06-21-2006 05:36 AM
Re: removing a log file that is 5 days old or older
find /var/tmp /xxx/yyy -type f -name '*.log' -mtime +4 -exec rm {} \;
I would replace the -exec rm {} \; with a more innocuous command (e.g. -exec ls -l {} \; ) until I got the find filters just right. You could also many the command more efficient by piping to xargs to group the rm's but that's overkill for a small number of files. Man find for details (and man xargs if you like).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 05:39 AM
тАО06-21-2006 05:39 AM
Re: removing a log file that is 5 days old or older
It's as simple as:
# find /path -xdev -name "*.log" -mtime +4 | xargs rm
...This finds any files named "*.log" that are older than 4-days (i.e not modified in that period).
Using '-xdev' prevents 'find' from crossing mountpoints. The double quotes around the name prevent the shell from expanding the metacharacters before the token is passed to 'find'. The use of 'xargs' avoids '-exec' which spawns a separate task for each file to be removed. Thus, 'xargs' makes your process kinder on system resources.
You can also add a '-t' switch to 'xargs' to create a trace of what will be removed. See the 'xargs' and 'find' manpages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 05:41 AM
тАО06-21-2006 05:41 AM
Re: removing a log file that is 5 days old or older
Ooops! I forgot to limit the removal to *files* ( '-f' ). The 'find' should be:
# find /path -xdev -type f -name "*.log" -mtime +4 | xargs rm
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 05:45 AM
тАО06-21-2006 05:45 AM
Re: removing a log file that is 5 days old or older
find /var/adm/syslog -type f -name "nameoflog" -mtime +4 | xargs rm
You can use wildcards.
You could also do a find and and -exec the results to rm -f
The key thing here is +mtime
A google search should have turned it up.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=998415
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1024386
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=122004
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 06:32 AM
тАО06-21-2006 06:32 AM
Re: removing a log file that is 5 days old or older
Lots of possibilities to manage the log files!
Available on the http:/gatekeep.cs.utah.edu site
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:15 AM
тАО06-21-2006 07:15 AM
Re: removing a log file that is 5 days old or older
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 07:19 AM
тАО06-21-2006 07:19 AM
Re: removing a log file that is 5 days old or older
# find /sourcedir -name '*.log' -mtime +4 -type f -local -exec rm {} \; > /tmp/logfile.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 11:48 AM
тАО06-21-2006 11:48 AM
Re: removing a log file that is 5 days old or older
find $LOGDIR/link* -type f -mtime +1 -exec mv {} $LOGDIR/Link-Archive \;
find $LOGDIR/*log -type f -mtime +1 -exec gzip {} \;
find $LOGDIR/*gz -type f -mtime +5 -exec rm {} \;
Thanks to all of you we have a solution -- thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2006 11:55 AM
тАО06-21-2006 11:55 AM