clean tmp folder

From WebHostingNeeds.com
Jump to: navigation, search

Following command delete 1 day old session files from /tmp folder.

vi /usr/local/bin/cleantmp
#!/bin/sh

find /tmp -type f -name 'sess_*' -mtime +1 | xargs rm -f
find /tmp -type f -name 'php*' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.zip' -mtime +1 |xargs rm -f
find /tmp -type f -name 'tmp_*' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.jpg' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.tmpvideo' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.params' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.gif' -mtime +1 |xargs rm -f
find /tmp -type f -name '*.png' -mtime +1 |xargs rm -f


chmod 755 /usr/local/bin/cleantmp


Set it to run daily

crontab -e

0 1 * * *  /usr/local/bin/cleantmp > /dev/null 2>&1




linux