tmpreaper – Cleans up files in directories based on their age
This package provides a program that can be used to clean out temporary-file directories. It recursively searches the directory, refusing to chdir() across symlinks, and removes files that haven't been accessed in a user-specified amount of time. You can specify a set of files to protect from deletion with a shell pattern. It will not remove files owned by the process EUID that have the `w' bit clear, unless you ask it to, much like `rm -f'. `tmpreaper' will not remove symlinks, sockets, fifos, or special files unless given a command line option enabling it to.
WARNING: Please do not run `tmpreaper' on `/'. There are no protections against this written into the program, as that would prevent it from functioning the way you'd expect it to in a `chroot' environment.
Install tmpreaper in Ubuntu
sudo apt-get install tmpreaper
or click on the link
After you install the package, you need to manually edit /etc/tmpreaper.conf and remove or comment the SHOWWARNING=true line to actually active it. Also review the settings in that file.
Note that /tmp and other directories are still cleaned at boot-time by the default /etc/init.d/*-bootclean.sh scripts.
If you want more options use man tmpreaper from your terminal