How can I use $HOME or ~/ in my log paths of launchd plist to run as LaunchAgent [duplicate]
You cannot use $HOME in these keys. You'll need to use the work-around shown in this answer:
how can I use $HOME, ~ or environment variable in plist file of LaunchDaemons
And then use ordinary shell scripting to redirect standard out and standard error to locations within $HOME. I.e. use a command similar to:
command >$HOME/launchd.stdout.log 2>$HOME/launchd.stderr.log
You can't use $HOME
in the plist
but you can configure it easily enough.
Once the plist is loaded on the proper computer (lets assume it is at ~/Library/LaunchAgents/local.testing.plist
for the sake of discussion)
All you need to do is enter two commands at the command line
defaults write "$HOME/Library/LaunchAgents/local.testing.plist" \
StandardOutPath "$HOME/launchd.stdout.log"
defaults write "$HOME/Library/LaunchAgents/local.testing.plist" \
StandardErrorPath "$HOME/launchd.stderr.log"
That will add the two log definitions with the full path, specific and correct for each computer.
It will also replace any existing values, so you don't need to worry about duplication.