Page 1 of 1
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 05:36
by Rava
I could not create the most recent Palemoon module because to extract the xz-tarball there needs some free space in /tmp
But currently my / is full:
Code: Select all
guest@porteus:~/.cache$ df -Tm /
Filesystem Type 1M-blocks Used Available Use% Mounted on
aufs aufs 388 388 0 100% /
The reason, mainly: Thumbnails in /home/guest :
Code: Select all
guest@porteus:~/.cache$ du -m thumbnails/
1 thumbnails/fail/gnome-thumbnail-factory
1 thumbnails/fail
91 thumbnails/large
148 thumbnails/normal
239 thumbnails/
239 MB in thumbnails is overkill in my book.
Therefore my question: is there a background way that not uses much system resources that will delete older thumbnails?
E.g. run it once an hour to keep the thumbnails/ folder in between a given size limit (e.g. not larger than 100 MB) by removing the oldest thumbnails.
The cron entry itself is not that much of a challenge.
All files and folders thumbnails/fail should be deleted regardless of age.
Then the thumbnails/large should be deleted, then the oldest from thumbnails/normal until the used space is once more below the threshold (e.g. 100MB)
I do not want to code that.
But I am sure somewhere in the vast space of the Linuxverse there already exists the solution for doing just that.
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 05:44
by Ed_P
I would delete all of them. The current ones will be rebuilt as you use the system.
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 06:24
by Rava
Ed_P wrote: ↑29 Mar 2023, 05:44
I would delete all of them. The current ones will be rebuilt as you use the system.
That's what I do, but I would like to have the system do it by itself when the folder got too large.
A PC system should be able to do such tasks on its own.
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 08:41
by donald
maybe delete only those files which have not been accessed for a given periode of time.
...via cron or script.
Code: Select all
find ~/.cache/thumbnails/{large,normal}/ -type f -atime +7 -delete
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 09:25
by Rava
Hi donald, wie geht's?
donald wrote: ↑29 Mar 2023, 08:41
maybe delete only those files which have not been accessed for a given periode of time.
...via cron or script.
Code: Select all
find ~/.cache/thumbnails/{large,normal}/ -type f -atime +7 -delete
That works.
But cron is run by root or not?
Therefore it must be
Code: Select all
find /home/guest/.cache/thumbnails/{large,normal}/ -type f -atime +7 -delete
since I hardly ever use the GUI file browser to go anywhere, as root I mostly use a terminal.
Can one automatically delete older thumbnails when that folder got too large?
Posted: 29 Mar 2023, 23:19
by donald
Rava wrote: ↑29 Mar 2023, 09:25
Hi donald, wie geht's?
passt scho..
Rava wrote: ↑29 Mar 2023, 09:25
But cron is run by root or not?
Every user can use cron if (s)he has a crontab.
seems porteus has a crontab for root but not for guest.
as guest check with
crontab -l if you have one.
If not, you can create a empty one with
crontab -e
Be aware that you will be in trouble if you don't know how to
use / exit vim/vi.
However, a cron job for that simple task (to delete thumbnails) would be overkill - imo.
Rava wrote: ↑29 Mar 2023, 09:25
since I hardly ever use the GUI file browser.........I mostly use a terminal.
I would use an alias in .bashrc to run the (delete old thumbs) command when needed.
Can one automatically delete older thumbnails when that folder got too large?
Posted: 30 Mar 2023, 03:23
by Rava
donald wrote: ↑29 Mar 2023, 23:19
However, a cron job for that simple task (to delete thumbnails) would be overkill - imo.
But i want it to be automated, so using cron to say, check twice a day and do a delete - but with few that 7 days ago, maybe one day, woulddo e trick and not does that have such a burden on the system, yes?
That would be this, yes?
Code: Select all
find /home/guest/.cache/thumbnails/{large,normal}/ -type f -atime +1 -delete
find /home/guest/.cache/thumbnails/fail/ -type f -delete
Can one automatically delete older thumbnails when that folder got too large?
Posted: 30 Mar 2023, 05:17
by donald
Rava wrote: ↑30 Mar 2023, 03:23
But i want it to be automated, so using cron to say....
Check what is in the root crontab
mine says that whatever script is in /etc/cron.daily/
runs at 19:30 every day.
If once a day is sufficient, put the "thumbs-delete" script in cron.daily.
Rava wrote: ↑30 Mar 2023, 03:23
That would be this, yes?
Code: Select all
find /home/guest/.cache/thumbnails/{large,normal}/ -type f -atime +1 -delete
find /home/guest/.cache/thumbnails/fail/ -type f -delete
should work - if not, add the path to the find binary in the script.
/usr/bin/find /home/guest/.cache/thumb....
I do not have a 'fail' folder (older porteus vesion), why not add it {large,normal,fail}?
Can one automatically delete older thumbnails when that folder got too large?
Posted: 30 Mar 2023, 14:53
by Rava
donald wrote: ↑30 Mar 2023, 05:17
I do not have a 'fail' folder (older porteus vesion), why not add it {large,normal,fail}?
I also do usually not have a fail folder. But I put it in extra since I think all fail thumbnails should be purged regardless of age since they are of no real use (whatever it means when a thumbnail is saved in the fail folder, I do not know)
But sure, having only one find line is more efficient.
Code: Select all
root@porteus:~# cat /etc/cron.daily/thumbs-delete
#!/bin/sh
/usr/bin/find /home/guest/.cache/thumbnails/{large,normal,fail}/ -type f -atime +1 -delete
I made it the same owner and permissions as the existing files, that is:
Code: Select all
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)