Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to run a script in intervals that requires a root user to execute. I created a plist that will call a script in ~/bin/

user@MBP:~$ ls -lah ~/bin/
-rw-r--r--   1 root       staff   566B Feb  6 23:44 test.plist
-rwxr-xr-x   1 root       staff    51B Feb  6 23:38

Here are the contents:

user@MBP:~$ cat ~/bin/test.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

user@MBP:~$ cat ~/bin/
cp /Users/user/bin/dummy.txt /etc

Then I symlinked the plist in /Library/LaunchAgents.

user@MBP:~$ ls -lah /Library/LaunchAgents/
lrwxr-xr-x   1 root  wheel    31B Feb  5 06:28 com.test.script.plist -> /Users/user/bin/test.plist

But all of this doesn't work. When I look at /var/logs/system.log it just say:

Feb  7 14:42:12 MBP[242] (com.test.script`[925]): Exited with code: 1
share|improve this question
Here's your solution :) – nuc Feb 7 '13 at 10:21
Thank you! Found out about /Library/LaunchDaemons running as root too on my own just a couple of minutes ago. :) – mptp Feb 7 '13 at 10:33

The man page for launchd.plist describes a UserName key that is required when running the job as root. Presumably, the value should be "root."

I'm no guru, but this seems to be the only thing you're missing — unless launch agents can't be symlinked.

share|improve this answer

So according to this SuperUser answer, you have to run launchctl as sudo in order to retain the permissions

sudo load -w /Library/LaunchDaemons/
share|improve this answer

Property lists in LaunchAgents also work, but you have to load both agents and daemons with sudo:

sudo chown root ~/bin/test.plist
sudo launchctl load /Library/LaunchAgents/test.plist

If the plist doesn't have a Disabled key, it is loaded automatically on the next login or restart, and -w is not necessary.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.