Clean .com.google.Chrome.* in /tmp
Recently, I found there were huge amount of files named .com.google.Chrome.* be created in my /tmp folder. Obviously the culprit is Chrome. However, after some research no solution is found to prevent Chrome creating these garbage.
| |
Update 2020/12/12
I found there are lots of .com.google.Chrome.* files in /tmp/snap.chromium/tmp :-( . Look at the ncdu results:
| |
Now the cleanup script has been updated.
The listed files were created within two days! Looks that it’s harmless, huh? Definitely NOT! By default, Linux will cleanup the /tmp at boot. If your system is rarely reboot:
- These files might make your disk full
- Huge amount of files in /tmp will block your system boot
Refer to this post: # A start job is running for Create Volatile Files and Directories
Therefore, I have to make a cron job to automatically cleanup /tmp periodically. The cleanup script cleanuptmp.sh:
The script will delete all .com.google.Chrome* directories with last modify time 12 hours before.
Since the /tmp/snap.chromium/tmp folder has restricted deletion flag t:
We need to add a cron job entry to root user by sudo crontab -e:
| |
It will cleanup the /tmp at 10:15 and 22:15 everyday.