- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: truncate huge file
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
тАО02-05-2010 06:29 AM
тАО02-05-2010 06:29 AM
I have a program running under unix which needs to trace too many actions done by the system each 15minutes
this leads the trace file become very huge in no time.
sometime it may exceed 3GB in 30 minutes
I tried to redirect the file to /dev/null but it couldn't do the job.
My question : is there a way that i can configure a script to continuously truncate the file for example each minute so that i can keep the file empty all the time.
thanks so much
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2010 06:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2010 06:40 AM
тАО02-05-2010 06:40 AM
Re: truncate huge file
>>to continuously truncate the file for
>>example each minute so that i can keep the
>>file empty all the time
If you are going to do this, why have the information logged to the file at all? Why not just modify the program so that it sends it output to /dev/null.
If you insist on trying to clean out the file, try:
# > filename
If that did not work, what did it do?
To run that regularly, just set it up in cron.
* * * * * > filename
Will runn the command every minute of every hour of every day.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2010 06:46 AM
тАО02-05-2010 06:46 AM
Re: truncate huge file
I have to believe that you mean the file is written to with such a frequency that you never find an instant when it's empty. As Patrick suggested, have the process redirect its output to '/dev/null' or cron a redirection of '/dev/null' to the logfile periodically. A cron entry to truncate the log every minute would look like:
* * * * * cat /dev/null > /path/to/mylog
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-05-2010 09:00 AM
тАО02-05-2010 09:00 AM
Re: truncate huge file
It would be helpful to see the actual code or cron entry you are running.
You will regret it but you can set up cron to > filename and run it regularly. Potential pitfall there is if there is an open file handle or file I/O happening on the file. Then you might get into an I/O wait state.
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
тАО02-11-2010 10:39 AM
тАО02-11-2010 10:39 AM
Re: truncate huge file
i think it was my mistake that i was doing the /dev/null in a wrong way ...
I didn't know that i had to remove the file first and then create the link using
ln -s /dev/null ./
thanks all for your help and sure thanks all for your time