0

I have a launchd job that is running every two minutes, but it is not on the sudo launchctl list.

I was changing the plist file, both the name of the file, and the Label key. I didn't unload it before hand but loaded the newly named file. Maybe that is what caused this but I'd still expect it in the list.

But it is never on the sudo launchctl list list. I checked cron as good measure too.

I've checked the other users. I see the script that the launchd job runs every two minutes when I do ps aux. Is there a way I can use ps aux to see which launchd process spawned it?

What else can I do to stop this thing? Restarting the server has to be a last resort, as would restarting launchd but if that's the only option that's the only option.

There's this question too, but no one answered it: https://apple.stackexchange.com/questions/240550/weird-launchd-behaviour-process-still-running-after-deleting-launchd-file-and-r

1

Is there a way I can use ps aux to see which launchd process spawned it?

If you use ps -ef, the first 3 entries on each line tell you the UID, PID and Parent PID of a process. Here's an example:

$  ps -ef|head -2
  UID   PID  PPID   C STIME   TTY           TIME CMD
    0     1     0   0 30May16 ??        25:05.63 /sbin/launchd

Between these three, you should be able to figure out the source of the process you're looking for. Here's a rather obvious example where I'm looking at softwareupdated (the daemon for softwareupdate):

First I look for the process and then confirm it using ps -ef <some_PID>. I've gotten into the habit of ending searches with grep -v grep to exclude grep from my results

$  ps -ef|grep softwareupdated|grep -v grep
  200  3711     1   0 30May16 ??         6:45.49 /System/Library/CoreServices/Software Update.app/Contents/Resources/softwareupdated
$  ps -ef 3711
  UID   PID  PPID   C STIME   TTY           TIME CMD
  200  3711     1   0 30May16 ??         6:45.49 /System/Library/CoreServices/Software Update.app/Contents/Resources/softwareupdated

The parent PID is numbered 1 so I check that:

$  ps -ef 1
  UID   PID  PPID   C STIME   TTY           TIME CMD
    0     1     0   0 30May16 ??        25:08.24 /sbin/launchd
  • nice! Worked like a charm. And it turned out it was under another user - I had assumed that sudo launchctl list would show all, but it is per user. Live and learn. Thanks for your help! – dgig Jun 9 '16 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.