Maintenance Shell Script – iMac (Lion)
Shell script performs certain maintenance tasks on OS X 10.7. It has been verified on OS X 10.5
##### Declaring some functions
iMac_uptime()
{
echo “”
echo -n “This iMac has been running for “
uptime | awk ‘{print $3, $4, $5 “mins” }’ | sed ‘s/,/ /g’ | sed ‘s/:/ hour /g’
}
cacheSize()
{
SIZE=0
for a in `du -sk /Library/Caches/ \
/System/Library/Caches/ ~/Library/Caches/ | cut -f 1`
do
SIZE=`expr $SIZE + $a`
done
SIZEINMEGABYTE=`expr $SIZE \/ 1024`
echo “The Caches size is $SIZEINMEGABYTE MB”
}
clearCache()
{
cacheSize
echo -n “cleaning Caches … “
sudo rm -r ~/Library/Caches/*
sudo rm -r /Library/Caches/*
sudo rm -r /System/Library/Caches/*
echo done
cacheSize
}
repairPermissions()
{
sudo diskutil repairPermissions / \
| grep -v “We are using special permissions for the file or directory” \
| grep -v “We are using a special gid for the file or directory”
# If you have more then one disk/partition please copy the code above
# and replace the “/” on the first line of code with the mount point of
# your partition / disk. Example: /Volumes/MyDisk
}
{
sudo diskutil verifyVolume /
# If you have more then one disk/partition please copy the code above
# and replace the “/” on the first line of code with the mount point of
# your partition / disk. Example: /Volumes/MyDisk
}
runPeriodic()
{
echo “running periodic jobs … “
sudo periodic daily weekly monthly
echo done
}
updatePrebindings()
{
echo “updating prebinding information … “
sudo update_prebinding -root /
echo done
}
verifyPreferenceFiles()
{
sudo plutil -s ~/Library/Preferences/*.plist
sudo plutil -s /Library/Preferences/*.plist
}
menu()
{
clear
date
echo “
1 Repair Filesystem Permissions
2 Verify Disks
3 Run Periodic (cron) jobs
4 Update Prebindings
5 Verify Preference Files
6 Display Caches size
7 Clear Caches
8 All
u iMac Uptime
q Quit Script
“
echo -n “Please enter your choice: “
read CHOICE
}
################################################################################
while true
do
menu
case $CHOICE in
1)
repairPermissions
echo “”
echo -n “Press ENTER to continue”
read
;;
2)
verifyDisks
echo “”
echo -n “Press ENTER to continue”
read
;;
3)
runPeriodic
echo “”
echo -n “Press ENTER to continue”
read
;;
4)
updatePrebindings
echo “”
echo -n “Press ENTER to continue”
read
;;
5)
verifyPreferenceFiles
echo “”
echo -n “Press ENTER to continue”
read
;;
6)
cacheSize
echo “”
echo -n “Press ENTER to continue”
read
;;
7)
clearCache
echo “”
echo -n “Press ENTER to continue”
read
;;
8)
verifyDisks
repairPermissions
verifyPreferenceFiles
runPeriodic
updatePrebindings
clearCache
echo “”
echo -n “Press ENTER to continue”
read
;;
u|U)
iMac_uptime
echo “”
echo -n “Press ENTER to continue…”
read
;;
q|Q)
exit 0
;;
*)
echo menu
;;
esac
done
No comments yet.
Leave a Reply
-
Recent
- Humble Prayer – Amen To That!
- Where’s faith when you need it?
- SCHOOL – 1950 vs. 2012
- East of Eden – Envy Leads Us Away From God
- Prayer – Work – Rest
- For the record: Pastoral Care
- It’s Just Common Sense
- This Month’s Church Magazine
- When Trouble Comes
- Maintenance Shell Script – iMac (Lion)
- PI: here’s the output file to 1,000,000 digits
- Top Films 2011
-
Links
-
Archives
- February 2012 (6)
- January 2012 (7)
- December 2011 (3)
- November 2011 (5)
- October 2011 (3)
- September 2011 (5)
- August 2011 (6)
- July 2011 (3)
- June 2011 (2)
- May 2011 (5)
- April 2011 (11)
- March 2011 (8)
-
Categories
-
RSS
Entries RSS
Comments RSS
