My purpose is to launch my application during every login but is being launched multiple times.
I copied my below plist file in to /Library/LaunchAgents and gave root ownership and chmod 600
<?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>en com.test.UserAgent</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Test/Test Agent.app/Contents/MacOS/Test Agent</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
When I login it loads and I can see it in launchctl list as
825 0 com.test.UserAgent
825 ==> Pid of my running application
When I quit my agent manually I see
_ 0 com.test.UserAgent
- ==> Which means application is currently not running
Then I relaunched my application manually
I see this in launchctl list
7075 0 com.test.workagent.30264
7075 ==> Pid of my application running
After some time my launchd is also trying to load launch agent service I see another instance of my application is being run.
8124 0 com.test.UserAgent ==> LaunchAgent Service
7075 0 com.test.workagent.30264. ==> Manually launched from applications
Expected behaviour is launch agent service should not launch my application again other than during login time