今天剛拿到擴充的ram, 想拿來作ramdisk存一些系統cache.
寫了一些很粗糙的script,
應該很多人有分享過了 各位有興趣可以參考看看
$(username) = 自己登入的帳號
1. 用Applescript先建立一個 Ramdisk的磁區, 將系統cache的檔案移動到ramdisk的磁區, 並建立連結.
並讓開機時執行這段Script.
do shell script "
if ! test -e /Volumes/RamDisk ; then
diskutil erasevolume HFS+ RamDisk `hdiutil attach -nomount ram://$((3*1024*1024*2))`
mv /Users/$(username)/Library/Caches /Volumes/RamDisk/
ln -s /Volumes/RamDisk/Caches /Users/$(username)/Library/Caches
fi
"
2. 寫一段script 讓登出時將cache檔案從ramdisk移動回硬碟
#! /bin/sh
rm /Users/$(username)/Library/Caches
mv /Volumes/RamDisk/Caches /Users/$(username)/Library/
存成/path/savecache.sh
3. 令這個script為可執行
chmod u+x /path/savecache.sh
4. 設定關機時執行這段script
sudo defaults write com.apple.loginwindow LogoutHook /path/savecache.sh
之前我用下列方法載我的mbp設置了一個ram disk的應用程式
在 Apple Script 中貼入以下的程式碼。
do shell script "
if ! test -e /Volumes/RamDisk ; then
diskutil erasevolume HFS+ RamDisk `hdiutil attach -nomount ram://$((2*1024*1024*2))`
fi
但是我發現設置以後chrome常常會自己關閉
也是在設置之後開完虛擬器關閉後常常會出現白色當機畫面
而且當我不執行他的時候cache檔都不知道存到哪去了
我想要取消這項功能




應該就是你所提到的
寫一段script 讓登出時將cache檔案從ramdisk移動回硬碟
#! /bin/sh
rm /Users/$(username)/Library/Caches
mv /Volumes/RamDisk/Caches /Users/$(username)/Library/
存成/path/savecache.sh
請問我是要再寫成一個應用程式執行他嗎
我是新手能不能有更詳盡的教學????謝謝你


zairabones wrote:
之前我用下列方法載我...(恕刪)
這是一支shell script, 寫好後(#2, #3), 在系統登出時去執行它(#4).
2. 寫一段script 讓登出時將cache檔案從ramdisk移動回硬碟
#! /bin/sh
rm /Users/$(username)/Library/Caches
mv /Volumes/RamDisk/Caches /Users/$(username)/Library/
# 存成/path/savecache.sh
3. 令這個script為可執行
chmod u+x /path/savecache.sh
4. 設定關機時執行這段script
sudo defaults write com.apple.loginwindow LogoutHook /path/savecache.sh
祝順利.
chmod u+x /path/savecache.sh
4. 設定關機時執行這段script
sudo defaults write com.apple.loginwindow LogoutHook /path/savecache.sh
這兩個部驟是寫在scrip中還是利用終端機
有沒有更詳盡的步驟

內文搜尋

X