You are not logged in.

#1 2024-10-08 11:55:38

TommyV6
Member
From: Poland
Registered: 2011-05-23
Posts: 12

Automatic temp cache etc. cleaning.

I`m trying to write small script to clean my Arch instalation.

My system is growing in this places:
/var/cache/ (some file cant be deleted)
/var/tmp/ in my system ~40GB after 8 weeks
/var/log/
/var/lib/libvirtu (cant be deleted my VM are here but I see some file ending with .tmp .cache in my system excluding disk images almost 40GB)

Can anyone point me what can be deleted ?

Offline

#2 2024-10-08 12:04:33

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,269
Website

Re: Automatic temp cache etc. cleaning.

For /var/cache/ see https://wiki.archlinux.org/title/Pacman … kage_cache.

/var/tmp/ sounds like some Flatpak bullshit but you should probably share the contents of the directory.

For /var/log/ see journald.conf(5).

No idea about the libvirt stuff though, sorry.

And please share the actual commands & error messages for your "can't be deleted" claims. Thanks.


Para todos todo, para nosotros nada

Offline

#3 2024-10-08 12:16:32

seth
Member
Registered: 2012-09-03
Posts: 58,664

Re: Automatic temp cache etc. cleaning.

The only way to prevent files from deletion by the root is to immute them (chattr +i)
As for "what can be deleted", if you're not mouting "noatime" have a look at the access timestamps.
There's no point in caches you frequently require because they'll just get regenerated.

Also most paths you posted are generic, anything could be in there and there's no way to tell what might be good for the bin w/o the absolute paths.

ls -Rhul

Offline

#4 2024-10-08 14:19:04

TommyV6
Member
From: Poland
Registered: 2011-05-23
Posts: 12

Re: Automatic temp cache etc. cleaning.

I dont want prevent files from detetion, I just want delete all temps... my 128GB SSD dedicated for /var is getting full soon. I`m ussing zstd compression but all files used by flatpak,aur,pacman are already compressed.

╭─user@arch11 /home/user  ‹system›
╰─$ ls -lh /var/cache
drwxr-xr-x root   root    168 B  Wed May 15 10:14:41 2024 ? cache
drwxr-xr-x colord colord    0 B  Fri May 17 17:13:32 2024  colord
drwxrwx--- root   cups    196 B  Tue Oct  8 10:14:10 2024  cups
drwxr-xr-x root   root     11 KB Fri Oct  4 15:02:18 2024  fontconfig
drwx------ root   root     18 B  Tue Oct  8 14:07:00 2024  ldconfig
drwxr-xr-x root   root      8 B  Fri May 17 17:13:32 2024  libvirt
drwx--x--x root   lightdm   0 B  Fri May 17 17:13:31 2024  lightdm
drwxr-xr-x root   root      0 B  Thu Jun 27 21:11:42 2024  lxc
drwxr-xr-x root   root    238 B  Tue Oct  8 13:13:31 2024  man
drwxr-xr-x root   root      6 B  Sat May 18 09:18:34 2024  pacman
lrwxrwxrwx root   root     13 B  Mon Jun  3 09:05:17 2024  pamac ⇒ private/pamac
drwxr-xr-x root   root      0 B  Tue Jul 30 22:45:29 2024  pkgfile
drwx------ root   root     10 B  Mon Jun  3 09:05:17 2024  private
drwxr-xr-x root   root    498 B  Tue Oct  8 09:09:43 2024  samba
drwxr-xr-x root   root     10 B  Mon Jun  3 09:04:54 2024  swcatalog
╭─user@arch11 /home/user  ‹system›
╰─$
╭─user@arch11 /home/user  ‹system›
╰─$ ls -lh /var/tmp/
drwxrwxrwx user user 62 B Tue Oct  8 13:53:07 2024  pamac
drwxr-xr-x user user  0 B Tue Oct  8 09:10:59 2024  pamac-build-user
drwx------ root root  6 B Tue Oct  8 09:08:44 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-bluetooth.service-DzZPyp
drwx------ root root  6 B Tue Oct  8 09:08:44 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-dbus-broker.service-LFlfVH
drwx------ root root  6 B Tue Oct  8 09:08:52 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-polkit.service-zhMY8J
drwx------ root root  6 B Tue Oct  8 09:08:44 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-systemd-logind.service-1Rsmu3
drwx------ root root  6 B Tue Oct  8 09:08:42 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-systemd-timesyncd.service-nqbmic
drwx------ root root  6 B Tue Oct  8 09:08:52 2024  systemd-private-377c7f68d2af4ff7b9446f519a6cd527-upower.service-jWMEvD
╭─user@arch11 /home/user  ‹system›
╰─$
I`m not using noatime at /var just relatime at / (root) and /home.
Thx to seth I just found ~50GB of StabilityMatrix in my /var/cache/private

Offline

#5 2024-10-08 14:25:16

seth
Member
Registered: 2012-09-03
Posts: 58,664

Re: Automatic temp cache etc. cleaning.

Please use [code][/code] tags. Edit your post in this regard.
If you're looking for what takes up the most space, see https://archlinux.org/packages/extra/x86_64/ncdu/

-u will show the access time, -R recurses.
You camn also find old files: https://bbs.archlinux.org/viewtopic.php … 2#p2196522

Offline

#6 2024-10-08 18:49:18

mountaintrek
Member
Registered: 2024-02-01
Posts: 36

Re: Automatic temp cache etc. cleaning.

No script necessary. All those items can be automatically managed via systemd and logrotate, systemd-timers and  journald configuration.

Areas to address

Package pacman-contrib contains paccache.timer (/var/cache/pacman).

Package logrotate contains logrotate.service (/var/log).

Service systemd-tmpfiles-clean.service (/tmp, /var/tmp).

More info on /var/tmp -  https://systemd.io/TEMPORARY_DIRECTORIES/

Other steps:

Check arch wiki for each area.

Check status of systemd services.

Use something like "find" or "du" to determine who is using the space.

Example commands:

systemctl list-timers

systemctl cat paccache.timer
systemctl cat paccache.service

systemctl status systemd-tmpfiles-clean
systemctl --failed

journalctl --disk-usage
sudo find /var -size +100M -print0 | xargs -0 ls -l -h

Offline

Board footer

Powered by FluxBB