0
USB 장치가 연결될 때마다 bash 스크립트를 실행하는 실행 에이전트가 있습니다. 한 번만 실행하고 싶지만 장치를 연결하면 스크립트는 10 초마다 계속 실행됩니다.실행 에이전트가 10 초마다 스크립트를 실행합니다.
#!/bin/bash
open -a "Spotify";
sleep 11;
내가 스크립트가 launchd에 생각을 할 때까지 최소한 10 초 실행하는 데 필요한 것을 읽으면서 나는 잠 11 추가 : 여기
<?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>com.example.program</string>
<key>Program</key>
<string>/Users/Peter/Desktop/test1.sh</string>
<key>LaunchEvents</key>
<dict>
<key>com.apple.iokit.matching</key>
<dict>
<key>com.apple.device-attach</key>
<dict>
<key>idProduct</key>
<integer>1476</integer>
<key>idVendor</key>
<integer>1356</integer>
<key>IOProviderClass</key>
<string>IOUSBDevice</string>
<key>IOMatchLaunchStream</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
스크립트입니다 : 여기
는 PLIST입니다 그 일을 끝냈다. 그러나 이것은 도움이되지 않습니다.
launchctl list com.example.program
을 실행하는 단말기에서
을 제공합니다
기본적으로"LimitLoadToSessionType" = "Aqua";
"Label" = "com.example.program";
"TimeOut" = 30;
"OnDemand" = true;
"LastExitStatus" = 0;
"Program" = "/Users/Peter/Desktop/test1.sh";
불행히도 이러한 키를 추가해도 차이가 없습니다. 흥미로운 점은 launchctl list com.example.program을 터미널에서 실행할 때 새로운 키가 보이지 않는다는 것입니다. 그게 정상인가요? –
@JohnSmith .plist를 다시로드해야하는 것 같습니다. 'launchctl unload/path/to/com.example.program.plist' 그리고'launchctl unload/path/to/com.example.program.plist'를 시도하십시오. (주의 : 이들과 함께'sudo'를 사용하지 * 마십시오. 에이전트가 아닌 데몬으로 취급 할 것입니다.) –
내가 다시로드했습니다. 작동하지 않습니다. –