I have a launchctl .plist file in /Library/LaunchDaemons as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

For those who are wondering, I use the slocate port from MacPorts instead of the native locate database that ships with OS X. This .plist job updates the slocate database specific to my home directory at 5:45 AM daily. The Umask setting of 077 makes the output file readable only by me. However, the file is created with the ownership of root; not what I want.

Is there a way to specify the ownership of the output file instead of the default of root? I realize I can run this as a LaunchAgent under ~/Library/LaunchAgents, but I prefer the job to run whether I am logged in or not, hence installing it as a LaunchDaemon.

I'm running OS X 10.10.3 Yosemite.

2 Answers 2


I have a few suggestions. According to to the manual, you can set the UserName key- https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html. You could use periodic with a shell script to run slocate and change the permissions of the database. Setup a user crontab. A user crontab will only run at the specified time.

  • Setting the UserName key fixed it. I can't believe I didn't see that or that it didn't occur to me. I was looking for chown when I could have been looking for process owner. Thank you. I set this as correct answer. Will upvote you when I have enough reputation. Commented May 20, 2015 at 17:10
  • someone who knows the topic well :) a + from me
    – Ruskes
    Commented May 20, 2015 at 17:17

Instead of /Library/LaunchDaemons use the user based ~/Library/LaunchAgents in your user library. Then the process will be executed as the logged in user, instead of the root account.

  • I prefer the job to run whether I am logged in or not. I figure since LaunchDaemons run as root, they would be able to change the owner of files they create. If that is not the case, what I will probably do instead is create another LaunchDaemon to change the ownership of that file and have it run well after the previous one completes. Wish there were a more elegant solution than that. Thanks for answering. Commented May 20, 2015 at 15:39
  • Actually, no, the strategy in my previous comment won't work, because both jobs will run when the computer boots or wakes up past the scheduled run time. Instead, on the second job, I will use StartInterval 300 or something to simply chown that file every 5 minutes. Still inelegant. Commented May 20, 2015 at 15:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .