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.
1 | du -csh .com.google.Chrome.* |
Update 2020/12/12 I found there are lots of
.com.google.Chrome.* files in
/tmp/snap.chromium/tmp :-( . Look at the
ncduresults: 1
2
3
4
5
6
7
8
9--- /tmp/snap.chromium/tmp -------------------------------------------------------------------------
/..
4.1 MiB [##########] /.com.google.Chrome.xTBobr
4.1 MiB [######### ] /.com.google.Chrome.0hcsFR
4.0 MiB [######### ] /.com.google.Chrome.YdhzL5
4.0 MiB [######### ] /.com.google.Chrome.nJ5W3A
4.0 MiB [######### ] /.com.google.Chrome.unS6es
...
Total disk usage: 6.8 GiB Apparent size: 12.1 GiB Items: 482530
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:
1 | !/bin/bash |
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: 1
2
3$ sudo ls -al /tmp/snap.chromium/
...
drwxrwxrwt 887 root root 1114112 Dec 12 11:40 tmp
We need to add a cron job entry to root user by
sudo crontab -e: 1
15 10,22 * * * /home/xxx/cleanuptmp.sh
It will cleanup the /tmp at 10:15 and 22:15
everyday.