Log Rotate and *NIX
This has changed since my days at Pyramid. There has been quite a lot of thinking and engineering about dealing with daemon logs. The places to look are via the syslogd, newsyslog project, you can see a the newsyslog man pages and using the keyword “rotate log”. The idea is that logs are rotated, although the names are not and that old logs are deleted. So the newest is called mypackage or mypackage.0 and the older logs increment the counter. Logs are generally kept in /var/log or /var/log/package_name and not in the package or product install tree. What a nob? There is a command ‘logrotate’; it can be installed using macports. It needs a a configuration file.
Or Liunux/MacOS out of the box, I found these pages
I have a problem today, I want to run a script periodically, on a laptop which will create a run log and I want to keep the logs tidy but each run is to have one log. I think I’ll write a function file since newlog is designed for daemons and I would need to manage the problem that my run needs to test the target log is empty before writing. I think I’ll refactor my functions to use logrotate. I now have the habit of placing the logs in /opt/local/log/appname and I place the conf files there too. It would be possible to place the conf files, if not job based in /etc and probably have a end of/start of day job rotate the logs.