How do I schedule a root command to run at intervals? 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/test.sh.

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 test.sh


Here are the contents:

user@MBP:~$ cat ~/bin/test.plist
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.test.script&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;sh&lt;/string&gt;
        &lt;string&gt;/Users/user/bin/test.sh&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;StartInterval&lt;/key&gt;
    &lt;integer&gt;30&lt;/integer&gt;
&lt;/dict&gt;
&lt;/plist&gt;

user@MBP:~$ cat ~/bin/test.sh
#!/bin/sh
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 -&gt; /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 com.apple.launchd.peruser.501[242] (com.test.script`[925]): Exited with code: 1
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.