1

I'm trying to wrap my head around launchctl.

I need to run the MacOS equivalent of systemctl status zabbix-agent

I am trying with launchctl print com.zabbix.zabbix_agentd but I get:

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>

I'm a bit at loss here, if anyone can help me, I would greatly appreciate it.

Thanks a lot in advance!

3
  • I think you need to call launchctl print GUI/(id -u) /Library/LaunchAgents/com.zabbix.zabbix_agentd, where id -u will return UID. You can replace id -u with a specific, desired UID. ss64.com/osx/launchctl.html
    – Zingam
    Commented Nov 5, 2022 at 15:23
  • Hello @Zingam! Thanks for your input. I'm getting the same error: $ launchctl print GUI 501 /Library/LaunchAgents/com.zabbix.zabbix_agentd 1🚫 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> Commented Nov 5, 2022 at 21:08
  • 1
    Please check my comment below for more ideas. Unfortunately it's a legacy syntax. That's all I can say at the moment.
    – Zingam
    Commented Nov 12, 2022 at 7:18

1 Answer 1

2

launchctl list will list display a list of current jobs, including the job's current PID (if it is running) and most-recent exit status (if it previously exited). Prepending sudo will also display system launchdaemons.

The unix command grep can be used to filter the output of stdin. So, to get the status of a job with the label com.zabbix.zabbix_agentd, you can do:

launchctl list | grep com.zabbix.zabbix_agentd

Prefix with sudo if zabbix-agent is installed as a system daemon.

6
  • Thanks for your input @Wowfunhappy! However, does launchctl list show the same output as systemctl info? Commented Jun 2, 2022 at 19:35
  • 3
    XNU is not Linux and there is no command that's exactly the same. I thought you were trying to figure out whether the job was running. If that's not it, what information are you actually hoping to find? Commented Jun 2, 2022 at 22:06
  • Thanks again for your help @Wowfunhappy! I am hoping to get the Control Group for the process and more precise job status info such as: Active: active (running) since Tue 2022-05-31 01:42:44 UTC; 2 days ago. Also, when there is some sort of problem, this status option shoots back a lot of useful info. Commented Jun 3, 2022 at 0:45
  • launchctl list is a legacy subcommand. Is there any alternative way to get the status reliably? Particulary from root I want to get the status/list of statuses for each logged in user. sudo -u user launchctl list returns a list of system daemons just like launchctl list from a root context.
    – Zingam
    Commented Nov 5, 2022 at 15:21
  • @Zingam Where did you read that launchctl list was legacy? I'm a bit surprised sudo -u didn't work for your use-case. I'm not that knowledgable about UNIX permissions, but my guess would be there's some sudo incantation necessary to get the output you're looking for. You might ask a new question. Commented Nov 5, 2022 at 19:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .