Mac OS X Cleaning temp files etc.

If you insist on running any maintenance tasks, you could run these commands in the Terminal:

WARNING! The “sudo rm -f” command is VERY dangerous, and can cause data loss if used incorrectly. Please, PLEASE, ensure that you type the commands listed below correctly, double and even triple check, I will not be held responsible if you hose your system.

1. “User-level” tasks that do not require a restart:

Run maintenance cron tasks

Code:
sudo periodic daily weekly monthly

Flush logs under your home directory

Code:
cd ~/Library/Logs
sudo rm -rf ~/Library/Logs/*

Flush cache under your home directory

Code:
rm -rf ~/Library/Safari/Downloads.plist
cd ~/Library/Caches
sudo rm -rf ~/Library/Caches/*

Flush Directory Service resolver cache (DNS, etc)

Code:
dscacheutil -flushcache

Update application pre-binding

Code:
sudo update_prebinding -root / -force

Repair disk permissions on boot volume

Code:
sudo diskutil repairPermissions /

Log out and back in to finalize the above steps.

2. “System-level” tasks that require a restart:

Clear the global cache database

Code:
cd /Library/Caches
sudo rm -rf /Library/Caches/*

Flush system cache entries

Code:
cd /System/Library/Caches
sudo rm -rf /System/Library/Caches/*

Flush LaunchServices Database (helps with multiple “Open With” entries)

Code:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

Flush Apple Type Server (ATS) cache (resolves issues with corrupt fonts some times)

Code:
sudo rm -rf `lsof | grep com.apple.ATS/annex.aux \
| grep Finder | cut -c 66-139`
sudo rm -rf /private/var/folders/*/*/-Caches-/com.apple.ATS

Repair disk permissions on boot volume

Code:
sudo diskutil repairPermissions /

Finally, restart your Mac after completing any system-wide maintenance tasks.