Last Updated: February 25, 2016
·
297
· fibo

clean /tmp on bash logout

Edit your .bash_logout, just copy and paste in your bash prompt the following command.

cat <<EOF >> $HOME/.bash_logout

# Clean /tmp folder with my files and folders older than 3 days.
find /tmp -mindepth 1 -maxdepth 1 -ctime +3 -user $USER -exec rm -rf {} \; 

EOF

It will keep your /tmp folder clean automatically.