- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Trim the logfile
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
08-27-2009 06:29 AM
08-27-2009 06:29 AM
In one of the server /tmp is 100% .. i checked out in the server , one logfile is occupying more space , so i need to trim the lines of the file, so how to find how many lines are there in that file and if i need to delete the first 1000 lines , what i have to do ?
Could anybody tell this .. Thanks in advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 06:36 AM
08-27-2009 06:36 AM
Re: Trim the logfile
First up all, if any process is using the file currently, then you won't be able to release the space used by the log file.
#cat filename |wc -l
This will give you the lines in that file.
Check if any process is using that file.
#fuser -u
If no process is using the file just zip it.
#gzip filename
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 06:42 AM
08-27-2009 06:42 AM
Re: Trim the logfile
You can use:
# wc -l filename
...to return a count of the number of lines in the file.
To delete the first 1000 lines, you could do:
# sed -e '1,1000d' filename > filename.new
# mv filename.new filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 06:42 AM
08-27-2009 06:42 AM
Re: Trim the logfile
# cat file|wc -l
use vi the file and do 1000dd and save the file.
but i would suggest to get the file copied and zip it using
cp -p file file.old
gzip file.old
trim the file
>file
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 07:47 AM
08-27-2009 07:47 AM
Re: Trim the logfile
If i use the sed command
it say as /tmp: write failed, file system is full.. help me !!!!11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 07:50 AM
08-27-2009 07:50 AM
Re: Trim the logfile
So try:
# sed -e '1,1000d' filename > /var/tmp/filename.new
# mv /var/tmp/filename.new filename
HTH
Duncan
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2009 07:53 AM
08-27-2009 07:53 AM
SolutionThe sed command stores the output in /tmp file system which is already full. So store the output in a different file system....
sed -e '1,1000d' /tmp/filename > /root/filename.new
Make sute /root/filename.new is corrrect, and then remove the file in the /tmp
rm /tmp/filename
mv /root/filename.new /tmp/filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2009 05:26 AM
08-28-2009 05:26 AM
Re: Trim the logfile
it say as /tmp: write failed, file system is full.. help me !!!!11
I am afraid you have reached the %100 in /tmp
if you check you can see:
# bdf /tmp
.. %100 ..
You have got stuck , so you need to delete some files to escape this situation. After you reach under %100 usage of /tmp you can work it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2009 12:02 AM
09-03-2009 12:02 AM
Re: Trim the logfile
Otherwise, just store the temporary .new file somewhere you have space left.
Best regards
Fredrik Eriksson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2009 02:30 AM
09-03-2009 02:30 AM
Re: Trim the logfile
search any core, tar or zip file is there or not in /tmp if found then move some other location or remove the same
#find /tmp -name core -print
#find /tmp -name *.zip -exec ls -l [] \;
what is the log file you found in /tmp please check the time stamp if its old update then take some action remove or move it.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2009 09:25 PM
12-06-2009 09:25 PM
Re: Trim the logfile
The log file is used by some of the process, so its any possible way to trim the log files , without the kiling the process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2009 01:57 AM
12-08-2009 01:57 AM
Re: Trim the logfile
Probably not. If the process opens, writes and closes, you can. Or opens with append. For the latter, you can't "replace" the file.