[launchd-dev] Stopping and unloading an agent from root-privileged application

James Bucanek subscriber at gloaming.com
Wed Jan 5 09:30:08 PST 2011


eveningnick eveningnick <mailto:eveningnick at gmail.com> wrote 
(Tuesday, January 4, 2011 12:57 PM +0200):

>How could i stop an agent from root-privileged application?
>
>if i am working in a terminal, i can type:
>
>% launchctl stop my.agent
>% launchctl unload /Library/LaunchAgents/my.agent.plist
>
>if i type
>
>% su
>

su? Really? That's so last century.

>i get an error (because this "sudo launchctl" controlls "System
>domain" launchd instance, not a "user session"'s one)
>
>Is there a way to explicitly specify from a Root terminal that i want
>to stop an agent that is loaded by launchd of the current user
>session?

Dude, root can do anything! Try this.

% sudo -u <username|#uid> launchctl stop my.agent
% sudo -u <username|#uid> launchctl unload /Library/LaunchAgents/my.agent.plist

where "<username|#uid>" is either the user account name or UID 
(in the form '#UID') of the user that owns the agent, as in: 
sudo -u '#502' launchctl stop my.agent

-- 
James Bucanek



More information about the launchd-dev mailing list