I've got a program that runs as a launchd agent, and I have stdout and stderr sent to a log file using the StandardErrorPath
and StandardOutputPath
keys. I'm quite keen on having stdout/stderr logged somewhere, and it seems like having launchd set this up would be the sensible thing.
(My intention was to suggest a file in ~/Library/Logs/
as a good setting. Then you can easily see the output in Console.app.)
Something I've noticed though is that launchd never seems to clean up these logs! I was expecting it to clear the log on each reboot, perhaps, or every few days, or something - but it seems not to. After a couple of weeks, I've got a 7MByte 22,000-line log file, virtually none of which is relevant. (It's highly unlikely you'd care about anything that happened before the last reboot, and in fact rather unlikely you'd care about anything that didn't happen in the last 15 minutes.)
Is there something I can do to stop the file growing indefinitely?