Quantcast
Channel: Using launchd to monitor a running program or process - Ask Different
Viewing all articles
Browse latest Browse all 3

Answer by user3439894 for Using launchd to monitor a running program or process

$
0
0

I'm posting this as an answer because it's to much for a comment and I believe I know what the issue may be, even without seeing the contents of the proc_check.shshell script.

I realized after reading again your question and ensuing comments, after deleting my first answer, the hint was the script worked from the command line but not when called by launchd.

When your User Agent .plist file is triggered, the $PATH it receives may not contain the paths to some commands/utilities that are being called within the script. The $PATH passed to the proc_check.shshell script is only:

/usr/bin:/bin:/usr/sbin:/sbin

So, any program that is called in the script that is not in the above $PATH or includes it's fully qualified pathname is not running when called by launchd.

To fix this, either use the fully qualified pathname for all executables called within the script, that are not in the above $PATH, or add a PATH=... statement after the shebang, where ... is the actual output of, echo $PATH in Terminal, e.g.:

#!/bin/bashPATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin

Note: The $PATH above is what's outputted by echo $PATH on my system and may well be different on yours.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>