Logs command
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
What is the command to purge log data older than say 60 days?
Added in 2 hours 11 minutes 41 seconds:
Ok, I've read up on the logrotate command but I'm not sure it does what I want which is to set the logs to 7 days max. Any advice?
Added in 2 hours 11 minutes 41 seconds:
Ok, I've read up on the logrotate command but I'm not sure it does what I want which is to set the logs to 7 days max. Any advice?
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
man logrotate 8 says
Code: Select all
# sample logrotate configuration file
compress
/var/log/messages {
rotate 5
weekly
postrotate
/usr/bin/killall -HUP syslogd
endscript
}
Code: Select all
/usr/bin/killall -HUP syslogd
First check which are the oldest now compressed files, and then look for a pattern that matches all the oldest files.
Then add that rm and its fitting for the older files only pattern into your logrotate setup file.
Currently my system is too freshly booted so I cannot assist you there:
Code: Select all
root@porteus:/var/log# ls -o messages*
-rw-r----- 1 root 251623 2022-10-26 04:28 messages
root@porteus:/var/log# ls -o *gz *xz
/bin/ls: cannot access '*gz': No such file or directory
/bin/ls: cannot access '*xz': No such file or directory
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
Thanks Rava.
Do you know what the current rotates are set to and where that setting is located?
This is what I see:

This is what I see:
Code: Select all
guest@porteus:~$ ls -oh /var/log/*log*
-rw-r--r-- 1 root 54K Oct 26 01:19 /var/log/Xorg.0.log
-rw-r--r-- 1 root 46K Oct 25 14:44 /var/log/Xorg.0.log.old
-rw-r--r-- 1 root 0 Feb 13 2021 /var/log/faillog
-rw-r--r-- 1 root 0 Apr 7 2000 /var/log/lastlog
-rw-r----- 1 root 1.2K Oct 25 14:44 /var/log/lxdm.log
-rw-r----- 1 root 1.8K Oct 25 14:44 /var/log/lxdm.log.old
-rw-r----- 1 root 0 Dec 4 2021 /var/log/maillog
-rw-r----- 1 root 7.6K Oct 26 01:19 /var/log/syslog
guest@porteus:~$ ls -oh /var/log/*mess*
-rw-r----- 1 root 203K Oct 26 01:21 /var/log/messages
guest@porteus:~$ ls -oh /var/log/*gz *xz
/bin/ls: cannot access '/var/log/*gz': No such file or directory
/bin/ls: cannot access '*xz': No such file or directory
guest@porteus:~$
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
No, I do not. ncmprhnsbl might know. Could also be there is currently no setup file for that and the system works with defaults.
Code: Select all
guest@porteus:~$ ls -oh /var/log/*log*
-rw-r--r-- 1 root 54K Oct 26 01:19 /var/log/Xorg.0.log
-rw-r--r-- 1 root 46K Oct 25 14:44 /var/log/Xorg.0.log.old
-rw-r--r-- 1 root 0 Feb 13 2021 /var/log/faillog
-rw-r--r-- 1 root 0 Apr 7 2000 /var/log/lastlog
-rw-r----- 1 root 1.2K Oct 25 14:44 /var/log/lxdm.log
-rw-r----- 1 root 1.8K Oct 25 14:44 /var/log/lxdm.log.old
-rw-r----- 1 root 0 Dec 4 2021 /var/log/maillog
-rw-r----- 1 root 7.6K Oct 26 01:19 /var/log/syslog
Code: Select all
rm /var/log/*log*.old

When you figured out which setup file to create new, or which one to tweak.

Cheers!
Yours Rava
Yours Rava
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
My prior files stats were from my safe system, no changes saved, these are from my changes=EXIT system.
And as you can see the logs are considerably bigger and I do have some .gz files.
Code: Select all
guest@porteus:~$ ls -oh /var/log/*log*
-rw-r--r-- 1 root 61K Oct 26 12:16 /var/log/Xorg.0.log
-rw-r--r-- 1 root 66K Oct 22 23:31 /var/log/Xorg.0.log.old
-rw-r--r-- 1 root 0 Feb 13 2021 /var/log/faillog
-rw-r--r-- 1 root 292 Jul 2 2021 /var/log/lastlog
-rw-r----- 1 root 1.2K Oct 26 12:15 /var/log/lxdm.log
-rw-r----- 1 root 1.6K Oct 22 23:31 /var/log/lxdm.log.old
-rw-r----- 1 root 0 Dec 4 2021 /var/log/maillog
-rw-r--r-- 1 root 8.2K Jan 17 2022 /var/log/slim.log
-rw-r----- 1 root 275K Oct 26 12:16 /var/log/syslog
-rw-r----- 1 root 39K Aug 11 20:04 /var/log/syslog.1.gz
guest@porteus:~$ ls -oh /var/log/*mess*
-rw-r----- 1 root 652K Oct 26 12:18 /var/log/messages
-rw-r----- 1 root 111K Oct 9 19:29 /var/log/messages.1.gz
guest@porteus:~$
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
Then you want to delete these most probably
Do a first as dry run to see if all files get deleted you want deleted and none get deleted you want to keep.
My freshly booted system with no changes= cheatcode gives me this:
Code: Select all
rm /var/log/*log*.old /var/log/*.gz
Code: Select all
ls -oh /var/log/*log*.old /var/log/*.gz
My freshly booted system with no changes= cheatcode gives me this:
Code: Select all
guest@porteus:~$ ls -oh /var/log/*log*.old /var/log/*.gz
/bin/ls: cannot access '/var/log/*log*.old': No such file or directory
/bin/ls: cannot access '/var/log/*.gz': No such file or directory
Cheers!
Yours Rava
Yours Rava
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
Code: Select all
guest@porteus:~$ ls -oh /var/log/*log*.old /var/log/*.gz
-rw-r--r-- 1 root 66K Oct 22 23:31 /var/log/Xorg.0.log.old
-rw-r----- 1 root 37K Aug 11 00:02 /var/log/debug.1.gz
-rw-r----- 1 root 1.6K Oct 22 23:31 /var/log/lxdm.log.old
-rw-r----- 1 root 111K Oct 9 19:29 /var/log/messages.1.gz
-rw-r----- 1 root 37K Aug 11 01:29 /var/log/secure.1.gz
-rw-r----- 1 root 39K Aug 11 20:04 /var/log/syslog.1.gz
-rw-r--r-- 1 root 16K Aug 11 00:02 /var/log/wtmp.1.gz
guest@porteus:~$


Rather than deleting them, and creating .wh files, is there a command to move them to trash like nemo supports?
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
Dunno. If the trash is e.g. /root/Thrash then just use this
Code: Select all
mv /var/log/*log*.old /var/log/*.gz /root/Thrash

Cheers!
Yours Rava
Yours Rava
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
From my changes-exit.conf file:
Code: Select all
!/root/.local/share/Trash/
!/home/guest/.local/share/Trash/
Code: Select all
guest@porteus:~$ ls -ohr /home/guest/.local/share/Trash
total 0
drwxr-xr-x 2 guest 880 Oct 28 11:34 info/
drwxr-xr-x 2 guest 880 Oct 28 11:34 files/
drwx------ 2 guest 40 Oct 7 18:46 expunged/
guest@porteus:~$
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
Then /home/guest/.local/share/Trash is trash for guest, but like I said, you have to figure out how "info/" works. Aka /home/guest/.local/share/Trash/info/
Added in 1 minute 10 seconds:
On my XFCE 4.16 box I only get this:
Added in 7 minutes 15 seconds:
thunar displays a "Trash" but won't tell me where exactly that folder lies:

(the dark violet areas are just privacy-censored folders and devices)
Added in 1 minute 10 seconds:
On my XFCE 4.16 box I only get this:
Code: Select all
guest@porteus:/$ ls -ohr /home/guest/.local/share/Trash
/bin/ls: cannot access '/home/guest/.local/share/Trash': No such file or directory
thunar displays a "Trash" but won't tell me where exactly that folder lies:

(the dark violet areas are just privacy-censored folders and devices)
Cheers!
Yours Rava
Yours Rava
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
A related thread: What Makes save.dat File Grow? There A "Prune" App For It?
Current settings: /etc/logrotate.conf
Added in 4 minutes 57 seconds:
Current settings: /etc/logrotate.conf
Added in 4 minutes 57 seconds:
Code: Select all
guest@porteus:~$ ls -ohr /home/guest/.local/share/Trash/info
total 8.0K
-rw------- 1 guest 118 Oct 8 15:12 Screenshot\ from\ 2022-10-05\ 00-20-29.png.trashinfo
-rw------- 1 guest 118 Oct 8 15:12 Screenshot\ from\ 2022-10-04\ 21-01-27.png.trashinfo
guest@porteus:~$ ls -ohr /home/guest/.local/share/Trash/files
total 324K
-rw-r--r-- 1 guest 188K Oct 5 00:20 Screenshot\ from\ 2022-10-05\ 00-20-29.png
-rw-r--r-- 1 guest 136K Oct 4 21:01 Screenshot\ from\ 2022-10-04\ 21-01-27.png
guest@porteus:~$ cat /home/guest/.local/share/Trash/info/*
[Trash Info]
Path=/home/guest/Pictures/Screenshot%20from%202022-10-04%2021-01-27.png
DeletionDate=2022-10-08T15:12:07
[Trash Info]
Path=/home/guest/Pictures/Screenshot%20from%202022-10-05%2000-20-29.png
DeletionDate=2022-10-08T15:12:07
guest@porteus:~$
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
^
Not that hard to emulate as a script, now, is it.
Just capture the current date and time when doing the delete = move to Trash like so
done in terminal as exampleHTH.
Not that hard to emulate as a script, now, is it.
Just capture the current date and time when doing the delete = move to Trash like so
Code: Select all
MYDeletionDate=$(date +%Y-%m-%dT%H:%M:%S)
echo $MYDeletionDate
Code: Select all
guest@porteus:~$ MYDeletionDate=$(date +%Y-%m-%dT%H:%M:%S)
guest@porteus:~$ echo $MYDeletionDate
2022-10-28T23:06:37
Cheers!
Yours Rava
Yours Rava
- Ed_P
- Contributor
- Posts: 8912
- Joined: 06 Feb 2013, 22:12
- Distribution: Cinnamon 5.01 ISO
- Location: Western NY, USA
Logs command
Thank you Rava.
In that I can't imagine me restoring a deleted log file and I don't save my trash folders when I shutdown I'm not overly concerned about the info files.
For my USB installed system straight deleting should be okay.

In that I can't imagine me restoring a deleted log file and I don't save my trash folders when I shutdown I'm not overly concerned about the info files.

-
- Full of knowledge
- Posts: 2104
- Joined: 17 Jun 2013, 13:17
- Distribution: Porteus 3.2.2 XFCE 32bit
- Location: Germany
Logs command
Those files/folder(s) are created when you actually send a file to Trash.Rava wrote: ↑28 Oct 2022, 20:34On my XFCE 4.16 box I only get this:Added in 7 minutes 15 seconds:Code: Select all
guest@porteus:/$ ls -ohr /home/guest/.local/share/Trash /bin/ls: cannot access '/home/guest/.local/share/Trash': No such file or directory
thunar displays a "Trash" but won't tell me where exactly that folder lies:
(the dark violet areas are just privacy-censored folders and devices)
- Rava
- Contributor
- Posts: 5424
- Joined: 11 Jan 2011, 02:46
- Distribution: XFCE 5.01 x86_64 + 4.0 i586
- Location: Forests of Germany
Logs command
Depends.
On one of my internal partitions (sda4) I created an empty test file in /mnt/sda4/tmp/TEST .
Cave! deleting any file via [delete] or via [shift]+[delete] makes no difference on sda4.
Usually [shift]+[delete] means: really delete, not move to Thrash, while [delete] means "move to Trash"
But like I wrote, if I use [delete] or [shift]+[delete] I always get this warning window

and after that this is what my Trash looks like:

…
… …
You might wonder "How could that be"…
I presume it is because in the root of /mnt/sda4 I have this empty file:
Code: Select all
guest@porteus:/mnt/sda4$ ls -o .Trash-1000
-rwxrwxrwx 1 guest 0 2022-01-31 05:36 .Trash-1000

So, your above assumption is only correct if a user did not create a .Trash-1000 file in the root partition of the device where (s)he deletes the file.

Added in 8 minutes 42 seconds:
On USB sticks I often create these empty files from keeping some OS (especially SM-Witless-OS) from creating Thrash folders:
Code: Select all
$recycle.bin
LOST.DIR
Recycled
Recycler
System Volume Information

Cheers!
Yours Rava
Yours Rava