The officially official Devuan Forum!

You are not logged in.

#1 2024-02-15 16:25:34

bilhook
Member
Registered: 2024-02-13
Posts: 47  

Clear logs

When I install I chroot /target and put noatime in fstab because thesedays we all use SSD's right.
Install, hopefully apt-cdrom will get into the 21st century and do something simples about add usb.

When I boot I rm /var/log/boot.0, and rm /var/log/dmesg.
And I, cat ; > /var/log/kern.log, and cat ; > /var/log/syslog
I would like to compile a script using the && operator say,
but I don't think I can pass a time argument to cat and then subsequently Ctrl Z.
Alternative?

Offline

#2 2024-02-15 17:25:39

aluma
Member
Registered: 2022-10-26
Posts: 533  

Re: Clear logs

I just disabled the rsyslog service.

P.S. Just in case, this is not recommended with systemd.

Last edited by aluma (2024-02-15 17:40:11)

Offline

#3 2024-02-16 16:21:45

bilhook
Member
Registered: 2024-02-13
Posts: 47  

Re: Clear logs

#!/bin/sh
rm /var/log/boot.0 &&
rm /var/log/dmesg &&
timeout 1 cat ; > /var/log/kern.log &&
timeout 1 cat ; > /var/log/syslog

Offline

#4 2024-02-16 21:24:38

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,132  

Re: Clear logs

Those timeout 1 cat sub commands serve no purpose apart from delaying execution (which is what timeout achives). Is that from some random web advice?

And why do you want to connect some sub commands? And in such obscure manner?
Your script effectively has three command lines:

rm /var/log/boot.0 && rm /var/log/dmesg && timeout 1 cat
> /var/log/kern.log && timeout 1 cat
> /var/log/syslog

Those are the portions up to the semi-colons, which sub-dvide them into those command lines whilst && joins sub commands such that the latter (the right-hand side sub command) is only executed if the former (the left-hand side sub command)  succeeds.

I'd suggest you rather want something like this:

#!/bin/sh
rm -f /var/log/boot.0 /var/log/dmesg
> /var/log/kern.log
> /var/log/syslog

I.e. remove the first two files ignoring that they might alread be removed, and then reset the other two to empty contents.

Offline

#5 2024-02-17 00:51:45

The-Amnesiac-Philosopher
Member
Registered: 2023-08-24
Posts: 250  

Re: Clear logs

bilhook wrote:

because thesedays we all use SSD's right

No sir...but I'm just some guy who like things old-school... tongue

Offline

#6 2024-02-17 01:12:29

ComputerBob
Member
From: The Sunshine State
Registered: 2018-10-11
Posts: 83  
Website

Re: Clear logs

^^^^^^
Same here.


ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 22 Million Views since 1998
My Massive Stroke
Help! (off-topic)

Offline

#7 2024-02-17 01:12:35

golinux
Administrator
Registered: 2016-11-25
Posts: 3,153  

Re: Clear logs

I am still on spinning rust . . . and at my age could very well have a lifetime supply in my stash . . .

Offline

#8 2024-02-17 04:56:57

GlennW
Member
From: Brisbane, Australia
Registered: 2019-07-18
Posts: 590  

Re: Clear logs

I've used "touch" to create a empty file... Not too sure about the date and time stamp.


pic from 1993, new guitar day.

Offline

#9 2024-02-17 10:31:36

aluma
Member
Registered: 2022-10-26
Posts: 533  

Re: Clear logs

There is a logrotate command.

logrotate -f, --force Force file rotation

The log is needed during setup, if everything works, why not completely disable it?
And turn it on if necessary.

Offline

#10 2024-02-17 11:30:05

Altoid
Member
Registered: 2017-05-07
Posts: 1,437  

Re: Clear logs

GlennW wrote:

Not too sure about the date and time stamp.

See here.

Best,

A.

Offline

#11 2024-02-17 14:05:57

aluma
Member
Registered: 2022-10-26
Posts: 533  

Re: Clear logs

It's nice to be in the company of literate people! smile

But can someone explain why all this fuss with rm /var/log/boot.0 ?
Will we replace cron and logrotate?
And what does SSD have to do with it? Has the number of rewrites become smaller due to this?

But SSDs are actually good, especially for older laptops with weak processors.

Offline

#12 2024-02-17 14:58:08

Altoid
Member
Registered: 2017-05-07
Posts: 1,437  

Re: Clear logs

Hello:

aluma wrote:

... replace cron and logrotate?

Don't think so.
I certainly won't, find them both to be quite useful.

... has the number of rewrites become smaller ...

Can't really say.
If it has, I think that it may probably be by a relatively insignificant amount.

That said, there's always fstrim running with cron.weekly.
And /var/log/trim.log to check and see that it is working properly.

No need to logrotate it.
Started 01/04/2021 and it is only 600 lines long / 30K.

Best,

A.

Offline

#13 2024-02-17 21:37:01

bilhook
Member
Registered: 2024-02-13
Posts: 47  

Re: Clear logs

I came up with the idea to cat a semi-colon to blank the file, as I remember using wvdial whick needed a semi-colon for a blank password.

I am very grateful ralph.ronnquist for your attention to the monkey scripting, which I obtained surfing the web.
The above script which I posted works.
But it is rubbish, obscure, abstruse, incorrect.
As you inform us, the script fails if the files already removed.
As to reset empty content, if I, cat ; > file, it stays like that forever, until I Ctrl Z, if I, timeout 1 cat ; > file, after one second it stops, it works.
I need to re-read numerous times, and comprehend, and understand, your superlative help.
Removing those two files, and resetting the other two, is exactly what I seek.
I do not want an archive of boot.gz & dmesg.gz, and I want empty kern.log & syslog, so I may study just one boot to login, if you understand me.
Your help is most champion, I will study, and learn.

Hello GlennW, I create files with touch all the time, perhaps everyone should.

In a world where nothing lasts forever, as for preserving our artefects (that's Australian & British spelling, which is correct from the Latin, I am spelling it Australian as a mark of respect to ralph.ronnquist!) I think rust is the most reliable, I think that's what banks prioritise, although I think the tax office is the most reliable.
I piece of ink and paper full of ones and zeros would be best, I suppose a quality microfiche is marvellous, thesedays could easily be machine read. I know that a lot of images/artworks are copied to A3 prints and preserved in a container.
The FBI would give us words of wisdom, but it wouldn't be concise, better asking the LAPD, they'd give us a second to none answer.
P.s. Emailing an attachment to yourself is handy.
And microsd cards are not gripped when they 'click' into devices is good to know.

I only really have one pedantic pet hate, it's not an adapter, it's an ADAPTOR!
By the way, if you're an American in Balmoral in Scotland, it's NOT Balmorale!

Last edited by bilhook (2024-02-17 22:11:41)

Offline

#14 2024-02-18 09:47:31

aluma
Member
Registered: 2022-10-26
Posts: 533  

Re: Clear logs

Amen!
Now everything is clear, I didn’t realize it right away. smile

Offline

#15 2024-02-18 17:01:58

chris2be8
Member
Registered: 2018-08-11
Posts: 266  

Re: Clear logs

>filename is the quickest way to empty a file. Or cat /dev/null >filename if you want it to be more readable.

Offline

Board footer