How can I add arguments to OSX launchd plist to pipe output to a log file?

前端 未结 3 1931
滥情空心
滥情空心 2021-02-10 05:53

I have tried many different variation on this but just can\'t get it to work.

I have a plist file:




        
3条回答
  •  一个人的身影
    2021-02-10 06:09

    The standard out and error keys are very useful, I redirected mine to the first terminal/shell as follows:

    StandardOutPath
    /dev/ttys000
    StandardErrorPath
    /dev/ttys000
    

    You can change ttys000 to another number (ttys001..2) if you have multiple terminals. You can find the terminal id by typing in the shell:

    tty
    

    This helped me to find out why I was getting console errors in OS X, I needed to have the full path for every command and full paths for directories I was CD'ing to in scripts.

    for instance grep is:

    /usr/bin/grep
    

    and commands installed by macports use other paths also, like:

    /opt/local/bin/lynx
    

    I also tried to chown root:wheel the plist, but this doesn't seem to be necessary, but probably not a bad idea to prevent someone from editing it to whatever...

    edit:changed mine back to normal user after I got some permission errors which turned out to be because the script was trying to make files in / without permission, needed to add full paths to output files too, which is weird as it worked the previous day.

提交回复
热议问题