0
對於launchd,可以在.plist文件中使用動態用戶名(考慮登錄用戶)。osx launchd plist動態登錄用戶名
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.software.script</string>
<key>Program</key>
<string>/Users/$username/script.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
我想要的用戶名是隨所登錄的用戶 這樣。
<string>/Users/user1/script.sh</string>
或
<string>/Users/user2/script.sh</string>
或
<string>/Users/usern/script.sh</string>
謝謝。