Sample Header Ad - 728x90

How to change a system startup daemon into a user launch agent

2 votes
1 answer
689 views
I'm using The Pritunl VPN software for one of my Mac's user accounts. The software installer creates a system LaunchDaemon found under /Library/LaunchDaemons called com.pritunl.service.plist Unfortunately this service remains active when I log out from the user profile it's intended for, causing the VPN connection to also remain active for different user accounts. What I would like to do is to remove this service from the /system/ and add it as a /user/username startup service. My intention is for the service to be started whenever I log in with the specific user and for it to stop whenever the user is logged out. What I've tried to do so far is to unload the system service, remove the .plist from the system directory /Library/LaunchDaemons and to move it to the user directory ~/Library/LaunchAgents after which I attempted loading and registering it for the specific user account. I've not yet succeeded in performing these steps correctly as the user account in question does not have root access.
Label
	com.pritunl.service
	ProgramArguments
	
		/Applications/Pritunl.app/Contents/Resources/pritunl-service
	
	KeepAlive
	
	Umask
	0
sudo launchctl list com.pritunl.service
{
	"LimitLoadToSessionType" = "System";
	"Label" = "com.pritunl.service";
	"OnDemand" = false;
	"LastExitStatus" = 0;
	"PID" = XXXX;
	"Program" = "/Applications/Pritunl.app/Contents/Resources/pritunl-service";
	"ProgramArguments" = (
		"/Applications/Pritunl.app/Contents/Resources/pritunl-service";
	);
};
Reference material I've used: https://rakhesh.com/mac/macos-launchctl-commands/ When trying to learn more about LimitLoadToSessionType I've only managed to find this archived older documentation. https://developer.apple.com/library/archive/technotes/tn2083/_index.html Trying to find it on the current documentation page hasn't resulted in what I'm looking for. https://developer.apple.com/search/?q=LimitLoadToSessionType I've found this excellent post detailing a lot of related subjects. https://apple.stackexchange.com/questions/366281/launchd-confusion-on-semantics-of-bootstrap-and-bootout-etc-after-reading-manu
Asked by Bismal (21 rep)
Oct 25, 2022, 03:07 PM
Last activity: Jul 13, 2025, 04:04 AM