I have the following launchctl command as a .plist file. It's loaded and set to run once a day but, it needs to run as root and I'm not sure how to verify this.
Also, this cron job basically CDs into a directory and runs a command. I'm sure launchd has a better way of specifying the directory where it's supposed to run the command.
How do I know it's run as root and is there a better way to write this?
Label
dev.project.frontpage.feedparser
ProgramArguments
cd
/Users/eman/src/project/trunk/includes/;
./feed-parser.php
-c
./feed-parser-config.xml
QueueDirectories
StartCalendarInterval
Hour
12
Minute
0
WatchPaths
Answer
What folder is the .plist stored in?
launchd runs Daemons (/Library/LaunchDaemons or /System/Library/LaunchDaemons) as root, and will run them regardless of whether users are logged in or not. Launch Agents (/Library/LaunchAgents/ or ~/Library/LaunchAgents/) are run when a user is logged in as that user. You can not use setuid to change the user running the script on daemons.
Because you will want to add it in /Library/LaunchDaemons you will want to make sure you load it into launchd with administrator privileges (eg. sudo launchctl load -w /Library/LaunchDaemons/com.apple.samplelaunchdscript.plist)
Check out man launchd for more information.
No comments:
Post a Comment