Sample Header Ad - 728x90

Running Launchd Services with Non Root User on macOS

0 votes
2 answers
4375 views
I am building a launchctl service which can run a java service. I am able to create launchctl service with root user and test start/stop/status/automatic start at reboot use cases. I am struggling with running same launchctl service with non root user(ec2-user in my case) My plist file looks like below Label siem ProgramArguments java -jar /Users/ec2-user/siem.jar RunAtLoad KeepAlive WorkingDirectory /Users/ec2-user StandardErrorPath /tmp/mycommand.err StandardOutPath /tmp/mycommand.out I have tried various steps to run the above service with ec2-user. UID for ec2-user is 501. ec2-user@ip-172-31-30-212 ~ % launchctl bootstrap gui/501 ~/Library/LaunchDaemons/siem.plist Bootstrap failed: 125: Unknown error: 125 Verified the content of plist file ec2-user@ip-172-31-30-212 ~ % plutil ~/Library/LaunchDaemons/siem.plist /Users/ec2-user/Library/LaunchDaemons/siem.plist: OK Tried bootstraping service with user ec2-user@ip-172-31-30-212 ~ % launchctl bootstrap user/501 ~/Library/LaunchDaemons/siem.plist Bootstrap failed: 5: Input/output error All of the above errors are not verbose and doesn't seem to find any way. **My goal : I want to run launchctl service with non root user.** **Environment Details:** **OS** : macOS on AWS EC2 Instance **macOS Version** : BigSur and Monterey **Update 1:** Checked system logs Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem): Service could not initialize: 20G224: xpcproxy + 23787 [86D1F823-583D-36B7-A047-55971A034143]: 0xd Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem.label): Service could not initialize: 20G224: xpcproxy + 23787 [86D1F823-583D-36B7-A047-55971A034143]: 0xd Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem): Service exited with abnormal code: 78 Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem): Service only ran for 0 seconds. Pushing respawn out by 10 seconds. Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem.label): Service exited with abnormal code: 78 Nov 26 17:51:23 ip-172-31-30-212 com.apple.xpc.launchd (siem.label): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Asked by SRJ (143 rep)
Nov 26, 2021, 04:53 PM
Last activity: May 21, 2023, 09:03 AM