macosplistinfo.plist

Added KeepAlive as true still process is not spawned after termination


I have create a plist with keepalive= true Still once process is killed it is not spawned again

<?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.dra.inycAent</string>
    
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/COMPANY_NAME PRODUCT_NAME.app/Contents/MacOS/PRODUCT_NAME</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>


Solution

  • For this to work, need to load the plist. Use "/bin/launchctl load -w -F your.plist" Make sure App is not running when you call this load. Better to do it after install. Use following sequence.

    1. After install in postinstall script make sure App is not running.

    2. Call "/bin/launchctl unload -w -F your.plist"

    3. Then call "/bin/launchctl load -w -F your.plist"