How do I use launchctl print?
I made a launchd service file then started it. Now I want to use the launchctl print
command but I'm not sure how.
I read: What is the difference between a `service-name` and a `service-target`? and tried using the id -u
command with the user/
prefix but it also didn't work.
How do I use the launchtl print command with my com.foo.http
service?
$ cat <<'EOF' > ~/Library/LaunchAgents/com.foo.http.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>Label</key>
<string>com.foo.http</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/python3</string>
<string>-m</string>
<string>http.server</string>
<string>3000</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
$ launchctl load ~/Library/LaunchAgents/com.foo.http.plist
$ launchctl list | grep com.foo.http
66590 0 com.foo.http
$ launchctl print ~/Library/LaunchAgents/com.foo.http.plist
Unrecognized target specifier. <service-target> takes a form of <domain-target>/<service-id>.
Please refer to `man launchctl` for explanation of the <domain-target> specifiers.
Usage: launchctl print <domain-target> | <service-target>
$ launchctl print com.foo.http
Unrecognized target specifier. <service-target> takes a form of <domain-target>/<service-id>.
Please refer to `man launchctl` for explanation of the <domain-target> specifiers.
Usage: launchctl print <domain-target> | <service-target>
$ launchctl print user/$(id -u)/com.foo.http
Could not find service "com.foo.http" in domain for uid: 501
$ launchctl version
Darwin Bootstrapper Version 6.0.0: Thu Apr 25 23:14:22 PDT 2019; root:libxpc_executables-1336.261.2~6/launchd/RELEASE_X86_64
As mentioned by @GordonDavisson in his comment How do I use launchctl print? use this command
launchctl print gui/$(id -u)/com.foo.http