View previous topic :: View next topic |
Author |
Message |
Roman_Gruber Advocate
Joined: 03 Oct 2006 Posts: 3846 Location: Austro Bavaria
|
Posted: Thu Dec 17, 2015 6:53 pm Post subject: xmas cleaning, how do i reduce a log file? |
|
|
Hi, I started to clean up my box.
Code: | ASUS-G75VW log # head emerge.log
1251371551: Started emerge on: Aug 27, 2009 11:12:31
1251371551: *** emerge unmerge dev-util/ccache
1251371552: === Unmerging... (dev-util/ccache-2.4-r7)
1251371553: >>> unmerge success: dev-util/ccache-2.4-r7
1251371553: *** exiting successfully.
1251371553: *** terminating.
1251970835: Started emerge on: Sep 03, 2009 09:40:35
1251970835: *** emerge sync
1251970835: === sync
1251970835: >>> Starting rsync with rsync://81.93.240.111/gentoo-portage
ASUS-G75VW log # ls --full-time emerge.log
-rw-rw---- 1 portage portage 121704700 2015-12-17 19:41:59.916228451 +0100 emerge.log
|
How can I keep the data starting from 1st of october 2015 and newer?
I know when i use splat, i need that log file to determine how long it took on the last emerge.
1251371552 <= these are the seconds in the unix time ofc.
--
Pesonally I would use
tail - (some value to choose) emerge.log >> new_log_file
head new_log_file
and do some iterations until i am there but that is just try and error, is there any cleaner approach?
I do not want to backup 120mb which i do not need. Just eats up disk space, slows down backups and aynthign else... |
|
Back to top |
|
|
VinzC Watchman
Joined: 17 Apr 2004 Posts: 5098 Location: Dark side of the mood
|
Posted: Mon Dec 21, 2015 12:42 pm Post subject: |
|
|
You could just use date and a regular expression with sed to find the trailing lines that matter to you:
Code: | date +%s # shows the number of seconds since 1970
date -d '<some valid date>' +%s # shows the number of seconds until the specified date |
For example:
Code: | sed -rne '/^'$(date -d 2015-10-01 -%s | sed -re 's/[0-9]{4}$//g')'/,$/p' < emerge.log |
will output only the lines after the first of October this year (2015)... provided you compiled at all on that date. Note I removed the last 4 digits Code: | sed -re 's/[0-9]{4}$//g' | from the date in seconds to account for the day – one day is 86400 seconds so theoretically we should remove the last five digits.
On a final note, I recommend you used logrotate to keep your log size under control. _________________ Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739! |
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6749
|
Posted: Mon Dec 21, 2015 3:31 pm Post subject: |
|
|
You could use logclean from the mv overlay which has particular algorithms for e.g. emerge.log |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|