osx - How to check for a launched process is loaded or not in MAC OS X from shell script? -
i have launchd process unload, command have used
launchctl unload /system/library/launchdaemons/costomscript.plist
it works fine if process loaded. if not loaded , executed command gives message saying no such process loaded. need have check, if .plist file loaded should unloaded otherwise not.
how can achieve this.. please help. thanks!!
you can information running processes launchctl
.
one possibility querying launchd
launchctl list
command.
list [-x] [label]
with no arguments, list of jobs loaded launchd in 3 columns. first column displays pid of job if running. second column displays last exit status of job. if number in column negative, represents negative of signal killed job. thus, "-15" indicate job terminated sigterm. third column job's label.
if plist loaded, should listed, otherwise not. first column contains pid
of process, check if process running, example:
$ launchctl list |grep myprocess 600 0 org.example.myprocess.1234
there launchctl print
command gives detailed output process. check if can use it.
print domain-target | service-target
prints information specified service or domain. domain output includes various properties domain list of services , endpoints in domain state pertaining each. service output includes various properties of service, including information origin on-disk, current state, execution context, , last exit status.
for example:
$ launchctl print gui/501/org.example.myprocess.1234 | grep state state = running