- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Trim Active Log
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-09-2006 12:11 AM
06-09-2006 12:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2006 12:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2006 12:16 AM
06-09-2006 12:16 AM
Re: Trim Active Log
A good way is to use the "guided" function with SAM.
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 01:23 AM
06-11-2006 01:23 AM
Re: Trim Active Log
I have a nice script that trims/archives syslog.log while managing syslogd. If interested, respond and I will send you the complete script. You could modify it for other log files.
Matthew from Boston
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 01:39 AM
06-11-2006 01:39 AM
Re: Trim Active Log
# sam
Routine Tasks --> System Log Files
then select the log file to trim.
else following command can be used:
cat /dev/null >
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 01:25 PM
06-11-2006 01:25 PM
Re: Trim Active Log
cd /logfile_directory
cp logfile logfile.old
cat /dev/null > logfile
Do not rename the file or create a new one since the file may be in use by a program. The above method allows for a program to continue adding to the logfile.
Logfile trimming is a regular task and will have to be repeated. Of course, the logfiles should be examined for any problems.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 02:32 PM
06-11-2006 02:32 PM
Re: Trim Active Log
#cp /path/your_log_file /path/backup_file
2, Trim
#>/path/your_log_file
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 05:00 PM
06-11-2006 05:00 PM
Re: Trim Active Log
But few doupts.
#/dev/null > active_log_file
What the command is doing.?
How it is trimming the log file.?
As per my Knowledge it is sending the content of active log to the null port ..If so.. Then how the Log file is get trimmed..
I got confused .. Anybody here to clear this confusion..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 05:12 PM
06-11-2006 05:12 PM
Re: Trim Active Log
But few doupts.
#/dev/null > active_log_file
What the command is doing.?
This command nullifies the active_log_file.
How it is trimming the log file.?
As per my Knowledge it is sending the content of active log to the null port ..If so.. Then how the Log file is get trimmed..
Take a look at # man null
NAME
null - null file
DESCRIPTION
Data written on a null special file is discarded.
Reads from a null special file always return 0 bytes.
EXAMPLES
To create a zero-length file, use either of the following:
cat /dev/null > file
cp /dev/null file
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 05:38 PM
06-11-2006 05:38 PM
Re: Trim Active Log
#/dev/null > active_log_file
What the command is doing.?
This command nullifies the active_log_file.
SUCH THAT THE ACTIVE LOG FILE CONTENT WILL BE ERASED IS IT SO...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 05:40 PM
06-11-2006 05:40 PM
Re: Trim Active Log
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 06:49 PM
06-11-2006 06:49 PM
Re: Trim Active Log
==========================================
i have some questions about /dev/null:
from man null:
Data written on a null special file is discarded.
Reads from a null special file always return 0 bytes.
To create a zero-length file, use either of the following:
cat /dev/null > file
cp /dev/null file
#ll null
crw-rw-rw- 1 bin bin 3 0x000002 Jun 12 01:15 null
#wc null
0 0 0 null
1.)i thought that /dev/null is a exe like rm or cat, but its a charactor special file.
anyhow its size also, zero. then how it is working?
2.) cat /dev/null > my_active_log_file
this command will delete the content of that "my_active_log_file". if so,
#rm my_active_log_file
#touch my_active_log_file also do the same function..right?
3). thru sam, we can do:
1. trim to zero, 2. To the Recommended size, 3. To a Line Number 4. To a Percentage,
how to do this four things thru commands?
ie how to trim a file to its 50% of original size?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 07:15 PM
06-11-2006 07:15 PM
Re: Trim Active Log
Sekar FYI,
#cat /dev/null >file
or
#>file
Will do the same thing.
Also it is the efficient way of trimming the log files. Allthough you can do it by other ways as well like removing and recreating files. But it will also involve two more steps of changing ownerships and permissions.
Also if some process tries to access the same while while you have removed it, it may experience some error.
So why to follow these many steps when you can do it with one simple commands itself.
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 07:41 PM
06-11-2006 07:41 PM
Re: Trim Active Log
I think That I got something But not sure.,
From the above reply that i find that
We can take the log file backup by using cp
#cp log_file log_file_old
then we can forwrd it to the null port such that
#/dev/null > log_file
such that the log_file become empty..
Is it right..
1. If so then what will happen to the new logs.. ?
2. And how the log file start generating logs again.. ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 07:47 PM
06-11-2006 07:47 PM
Re: Trim Active Log
#/dev/null > log_file
and
# > log_file
both will re-fresh your logfile with no data inside (make the log file empty) but keep the time-stamp of that file ( day of creation, owner, permission)
By do-ing as this way. Your application can continue to put log to log-file as usual.
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 07:52 PM
06-11-2006 07:52 PM
Re: Trim Active Log
Its Amazing Response and i Got The solution from the last reply..
Thanks to All..
I am closing the Thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 07:54 PM
06-11-2006 07:54 PM
Re: Trim Active Log
There are quite a few ways to trim a file under HP-UX as in...
# > active_log_file
or
# cat /dev/null > active_log_file
or
# cp /dev/null active_log_file
or
SAM
...SAM is able to manipulate the file size in more ways because behind the scenes it calls the std C lib APIs like truncate and ftruncate.
You can develop your own C program(s) utilizing those lib routines and wrap them in a menu driven shell script which essentially provides the same functionality as SAM does.
~hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 08:08 PM
06-11-2006 08:08 PM
Re: Trim Active Log
you could use logrotate:
http://forums1.itrc.hp.com/service/forums/bizsupport/questionanswer.do?threadId=686249
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2006 11:48 PM
06-11-2006 11:48 PM
Re: Trim Active Log
/dev/null can be used to write or read. When it is used as a source file, it is an empty file. When you simply cat the null file and redirect it into another file, the destination file is reduced to zero length. This is *NOT* the same as:
rm logfile
touch logfile
Several mistakes have occurred using rm. First, the logfile has very specific permissions and removing the file means that these permissions and ownership must be restored for proper operation. Now if the logfile is still open, then the rm does not work correctly and the touch simply updates the timestamp. DON'T use rm.
Trimming a logfile to 50% requires a script to calculate the number of records, read that many records from the start into the second logfile. Then using tail (it has limitations on size) or awk, read the last half into a temp file, then cp the tempfile on top of the current file and delete the tempfile. Not easy at all. It is much simpler to copy the current file then zero the current file.
Bill Hassell, sysadmin