
如何在我的 OS X Yosemite Macbook 上每次啟動時製作一個 python 腳本 rusn?我希望它也有 sudo 權限。
答案1
此類命令的正確位置是文件/etc/rc.local:你使你的文件可執行(chmod 755 檔案名),放置線
/Full/Path/To/File
在 - 的裡面/etc/rc.local文件,就是這樣。
然而,從優勝美地開始,/etc/rc.local不再受到尊重。為了解決這個問題,請放置以下文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key> <string>local.localhost.startup</string>
<key>Disabled</key> <false/>
<key>RunAtLoad</key> <true/>
<key>KeepAlive</key> <false/>
<key>LaunchOnlyOnce</key> <true/>
<key>ProgramArguments</key>
<array>
<string>/etc/rc.local</string>
</array>
</dict>
</plist>
作為 /Library/LaunchDaemons/local.localhost.startup.plist 但此時,您還必須確保/etc/rc.local是可執行的。