1

I want to configure a launchd daemon to run a virus scan daily. I have written a .plist and manually loaded it using launchctl load but it doesn't seem to run. I wanted to modify it to try and debug why. However, it doesn't seem to be modifiable.

Here's the output of sudo launchctl list org.macports.clamscan:

{
        "LimitLoadToSessionType" = "System";
        "Label" = "org.macports.clamscan";
        "TimeOut" = 30;
        "OnDemand" = true;
        "LastExitStatus" = 19968;
        "Program" = "clamscan";
        "ProgramArguments" = (
                "clamscan";
                "--suppress-ok-results";
                "-l";
                "/var/log/clamscan.log";
                "-r";
                "/Users";
        );
};

I tried to unload it to edit it and reload it but it didn't seem to work:

$ sudo launchctl unload org.macports.clamscan
Password:
$ sudo launchctl list org.macports.clamscan
{
        "LimitLoadToSessionType" = "System";
        "Label" = "org.macports.clamscan";
        "TimeOut" = 30;
        "OnDemand" = true;
        "LastExitStatus" = 19968;
        "Program" = "clamscan";
        "ProgramArguments" = (
                "clamscan";
                "--suppress-ok-results";
                "-l";
                "/var/log/clamscan.log";
                "-r";
                "/Users";
        );
};

I tried to modify it to replace clamscan with a script so I can verify which arguments it was being called with. However, when I try and load it, it complains that it's already loaded.

$ sudo launchctl load ~/Code/org.macports.clamscan.plist 
/Users/Stephen/Code/org.macports.clamscan.plist: service already loaded

Aside from rebooting is there a way to edit an installed launchd job? This is for Sierra.

1

You can tell launchd to remove it from its cache and reread from disk. From the man page:

 uncache service-name
          This subcommand instructs launchd to bypass its service cache
          for the named service and instead read the service's configu-
          ration file directly from disk.  launchd maintains an in-mem-
          ory cache of XPC service configuration files to minimize the
          disk I/O. This subcommand will remove a cached entry so that
          developers may more rapidly iterate on a service's configura-
          tion. It should not ever be used as part of production work-
          flow.
  • Command is not yet implemented. in version Darwin Bootstrapper Version 5.3.0. – Itachi Jan 22 at 3:49

You must log in to answer this question.

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