Today's article has you deleting old logs to free up some disk space...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,160
Reaction score
5,531
Credits
49,658
It's just a quick article about cleaning out your logs. It's a good skill to have, mostly aimed at people with few resources or new people who don't know how to do this already.


I do love me some feedback.
 


captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,802
Reaction score
1,900
Credits
17,251
what the --rotate flag does is not going to be obvious to everybody .

your post may lead someone to comment on the package "logrotate" those that work or do administration on apache

basics of running manually :

edit /etc/logrotate.conf and add log file :

Code:
/var/log/httpd/andrinaWeb.com-access_log
{
 minsize 1M
    rotate 1

 }
then run
Code:
sudo logrotate -vf /etc/logrotate.conf


:
 
Last edited:
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,160
Reaction score
5,531
Credits
49,658
what the --rotate flag does is not going to be obvious to everybody .

No? Hmm... I thought it'd be relatively obvious, but I could *easily* be wrong.

Let me mull it over a bit. Feel free to add your comment from here to a comment there, though the format there is <code>foo</code>.
 

bob466

Active Member
Joined
Oct 22, 2020
Messages
287
Reaction score
222
Credits
2,134
I'm always wary of commands that "clean" your system.
scared0002.gif


Not saying anything about your command but about a year ago a guy with a Linux youtube channel posted a command that will "clean" your system...well it did...it removed wine and some other stuff that I didn't want removed.
mad0016.gif


Lucky for me I created an Image of the Drive before I ran the command. I do have safe commands I run every few months to clean the very small amount created by Mint.
happy0035.gif
 

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,802
Reaction score
1,900
Credits
17,251
if you look at my post above referencing logrotate ; you can see you decide which files will be cleaned by adding to config; also files getting truncated is avoided

not trusting anything posted on any social media is a good approach

but the one posted by KGIII is one of the kosha ones
 
Last edited:

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,802
Reaction score
1,900
Credits
17,251
Feel free to add your comment from here to a comment there, though the format there is <code>foo</code>.
systemd has within it the functionality to create and store logs of processes My limited understanding is that from boot up, because processes and daemons are running, logs will likely to be produced on the fly as well as those already stored to file.

The use of the rotate flag is a way of marking the current active log files as an archive and creating a fresh logfile. The flush flag evokes the journal daemon to flush any log data stored in

Code:
 /run/log/journal/ into /var/log/journal/

So you can do both to get things started with this command :

Code:
sudo journalctl --flush --rotate

Then to reduce the volume of systemd log files you can use time such as :

Code:
sudo journalctl --vacuum-time=10s


the above cleans out everything to logs produced in the last 10 seconds , or:

Code:
 sudo journalctl –vacuum-size=50M

In the above we trim log size to 50 mebabytes

Now it maybe that you are doing some web development on your PC. Systemd won’t touch those unless you make use of :
Code:
 Apache Module mod_journald

But there is another approach if you like to keep things separate, using the package logrotate , even better if your, an ex Slackware control freak , you will of course want to evoke things manually On Arch you can install the pkg using :
Code:
sudo pacman -S logrotate

Then you add the files you want to trim in the config file
Code:
 /etc/logrotate.conf
such as :
Code:
 /var/log/httpd/andrinaWeb.com-access_log { minsize 1M rotate 1 }

in the above i write with path the logfile that when logrotate is evoked will clear I will do that , manually when i think its an appropriate time using :
Code:
sudo logrotate -vf /etc/logrotate.conf
v is verbose and f flag is force
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,160
Reaction score
5,531
Credits
49,658
I'm always wary of commands that "clean" your system.

This particular one just removes some log files. It's reasonably harmless.

but the one posted by KGIII is one of the kosha ones

So far, nothing on my site has broken anyone's computer. I write many of the articles based on the notes I've compiled over the years, so everything is usually well-tested.

v is verbose and f flag is force

Thanks for leaving the comment. It's almost enough for an entire article by itself. I try pretty hard to keep the articles consistent in length, having done some testing to see what people actually do while on the site.
 

Oldhabbits

Member
Joined
May 24, 2021
Messages
60
Reaction score
44
Credits
415
I use bleachbit for that... ;-)
 
OP
K

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
6,160
Reaction score
5,531
Credits
49,658
I use bleachbit for that

You can also do some file clearing with Stacer, which is a bit different and typically runs resident on your system, sitting there in the tray.
 

Condobloke

Well-Known Member
Joined
Apr 30, 2017
Messages
4,514
Reaction score
3,941
Credits
25,363
Go careful with bleachbit...nastiness can happen.

Stacer is far more informative....and less prone to nastiness.
 

Oldhabbits

Member
Joined
May 24, 2021
Messages
60
Reaction score
44
Credits
415
You can also do some file clearing with Stacer
Hey, thanks for the tip, I will test Stacer very shortly...
Cheers,
Eddy
 

Oldhabbits

Member
Joined
May 24, 2021
Messages
60
Reaction score
44
Credits
415
Go careful with bleachbit...nastiness can happen
Never had any problems with it, though... But I am carefull in settings for which boxes I tick ! ;-)
Cheers,
Eddy
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top