launchctl submit
어떤 이유로 종료되면 이미 프로그램을 다시 실행해야합니다
submit -l label [-p executable] [-o path] [-e path] -- command [args]
A simple way of submitting a program to run without a configura-
tion file. This mechanism also tells launchd to keep the program
alive in the event of failure.
-l label
What unique label to assign this job to launchd.
-p program
What program to really execute, regardless of what fol-
lows the -- in the submit sub-command.
-o path Where to send the stdout of the program.
-e path Where to send the stderr of the program.
false로 KeepAlive를위한 SuccessfulExit 기준이 오류로 종료하는 경우, 다시 프로그램을 실행 설정하려면 :
<?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>Label</key>
<string>test</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>n=$((RANDOM%2));say $n;exit $n</string>
</array>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>StartInterval</key>
<integer>60</integer>
</dict>
</plist>
launchd 작업을 조절하므로 프로그램을 다시 시작하는 데 약 10 초가 걸립니다.
왜이 작업을 수행하려고합니까? 내가 당신의 정확한 문제를 안다면 또 다른 해결책이있을 수 있습니다. – jamespick
'launchctl submit'을 원하셨습니까? load는 인수를 취하지 않습니다. 이 경우 submit 명령은 간격을 지원하지 않으므로 .plist 버전을 사용해야합니다. – gaige
@gaige 예 죄송합니다. – 735Tesla