1

I'm created a LaunchDaemon script to run backups for our git repos. I want to run the process as a particular user (git) with the Std & Err logs output to /var/log

I get permission denied when launchd tries to create the logs.

Aug 18 10:15:00 server com.apple.launchd[1] (com.gitlab.backup[40752]): open("/var/log/gitlab_backup.log", ...): 13: Permission denied
Aug 18 10:15:00 server com.apple.launchd[1] (com.gitlab.backup[40752]): open("/var/log/gitlab_backup_err.log", ...): 13: Permission denied

I was sort of expecting launchd to create the logs and chown to the user specified in the key UserName

Is the only option to log to a folder where the user has write access?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.stardotstar.gitlab.backup</string>
    <key>UserName</key>
    <string>git</string>
    <key>WorkingDirectory</key>
    <string>/Users/git/gitlab</string>
    <key>EnvironmentVariables</key>
    <dict>
        <key>RAILS_ENV</key>
        <string>production</string>
    </dict>
    <key>ProgramArguments</key>
    <array>
        <string>bundle</string>
        <string>exec</string>
        <string>rake</string>
        <string>gitlab:backup:create</string>
    </array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>10</integer>
        <key>Minute</key>
        <integer>20</integer>
    </dict>
    <key>StandardOutPath</key>
    <string>/var/log/gitlab/gitlab_backup.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/gitlab/gitlab_backup_err.log</string>
</dict>
</plist>
Rob
  • 247
  • 1
  • 3
  • 13
  • 1
    As workaround you may create `/var/log/gitlab_backup.log` and `/var/log/gitlab_backup_err.log` by your own and `chown` them to `git` user – user1700494 Aug 18 '16 at 09:40
  • yeh sure or create a gitlab folder and chown that but I thought maybe i was doing something wrong – Rob Aug 18 '16 at 09:47

0 Answers0