Search
Enter Keywords:
Home
OS X System Optimization Script PDF Print E-mail
User Rating: / 0
PoorBest 
Written by Michael Salsbury   
Friday, 03 June 2005

The script below combines the functions of several others on this site into one "optimization" script.  It cleans up the various caches, updates prebindings to improve system performance, repairs permissions on the startup disk, and reboots the computer.

It must be run with administrator privileges in order to work properly.

As with all my scripts, this one is offered "as is" without warranty or support.  If you choose to use it, you accept all liability and responsibility for whatever might happen to your system (good or bad).

#!/bin/csh
#
# Optimizes the system.
#
#
# Updated: October 5, 2004
# By: Michael Salsbury
#
echo " "
echo "This script will optimize the system."
echo " "
echo "Specifically, it cleans the Internet, System, and Font Caches,"
echo "repairs permissions on the startup disk, and then performs a "
echo "re-prebind of the system. "
echo " "
echo "To ensure the continued stability of the system, it should be"
echo "rebooted after the script finishes its execution."
echo " "
echo "Enter the admin/root password when prompted."
echo " "
echo "Cleaning up system caches..."
sudo rm -f /System/Library/Caches/*
sudo rm -f /Library/Caches/*
sudo rm -f /System/Library/Extensions.kextcache
echo "Cleaning up user caches..."
cd /Users
foreach d ( * )
 
  if ($d != "Shared") then
 
     echo Deleting Internet cache files...
     # This removes the Safari cache files for the user.
     sudo rm -rfv /Users/$d/Library/Caches/Safari/*
     sudo rm -rfv /Users/$d/Library/Safari/Icons/*/*/*.cache
     # This removes the Netscape 7 cache files.
     sudo rm -rfv /Users/$d/Library/Mozilla/Profiles/*/*/Cache/*
     # This removes the IE 5.2 Cache files.
     sudo rm -rfv /Users/$d/Library/Caches/MS\ Internet\ Cache/*
     # This removes Firefox Cache files.
     sudo rm -rfv /Users/$d/Library/Mozilla/Profiles/Default\ User/*.slt/Cache/_CACHE_*
     sudo rm -rfv /Users/$d/Library/Mozilla/Profiles/default/*/Cache/*
     sudo rm -rfv /Users/$d/Library/Application\ Support/Firefox/Profiles/*/Cache/*
     # This removes Opera 8 Caches.
     sudo rm -rfv /Users/$d/Library/Caches/Opera\ Cache/Cache*/*

  endif
end
echo " "
echo "Updating prebinding..."
sudo update_prebinding -root /
echo " "
echo "Repairing permissions..."
cd /Volumes
foreach d ( * )
  if (-w "/Volumes/$d") then
    sudo diskutil repairPermissions /
  endif
echo " "
echo "Attempting to reboot..."
sudo shutdown -r now
echo "Finished."
echo "Please reboot now if the script does not do so automatically."
echo " "