Home > Bash, Linux > Clean thumbnail cache with a cron script

Clean thumbnail cache with a cron script

In a Linux machine using Nautilus there are a folder called “.thumbnails” in the users home directories. This folder can grow quite a lot when the system are building new thumbnail images for your pictures. A good idéa can be to clean this out every month.

Make this script in your home folder:

find ~/.thumbnails -type f -atime +7 -exec rm {} \;

The script removes files not used in seven days. Make the script executable:

chmod u+x cleanthumbs.sh

Run the script with cron:

crontab -e

Add a line to the bottom of the file to run your script once a month:

@monthly /home/yourusername/cleanthumbs.sh

Test the script manually before adding it to the crontab. First check how big your thumbnail folder are with the command:

du -sh $HOME/.*

This will list all hidden folders in your home folder. Run the script and then check the folder size again. My thumbnail folder decreased in size from 230MB to 4MB.

Categories: Bash, Linux Tags:
  1. No comments yet.
  1. No trackbacks yet.