Introduction
Removing temporary files left over in your /tmp folder, is not as easy as it looks like. At least not on a multi-user system that's connected to a network.
If you do it the wrong way, you can leave your system open to attacks that could compromise your system's integrity
Many people have query that how to automatically clean /tmp folder. I’ve made a simple script to do this task effortlessly.
#!/bin/bash
for i in `/bin/ls -1 /tmp | egrep -v "eaccelerator|mysql.sock|lost+found|CleanTmp.sh"`;
do rm -rfv /tmp/"$i";
done ;
/etc/init.d/httpd restart;
/etc/init.d/mysql restart
If you have other files which you want to exclude and that you do not want to delete that add it after lost+found|
What you have to do is add the above script in any file and add a cron to run the file as per your convenience.
If you have any questions then, please keep them coming in the comments and if you want you can contact me.
No comments:
Post a Comment