When working with large web projects over a longer period of time on a local development machine. You may notice that your disk space (especially with a SSD) is running low and one of the reason could be your log files. So why not rotate them an automatically delete older ones.
On most Linux based servers you would use the logrotete script to handle log files, but not in OS X. It comes with newsyslog and its configuration can be found in /etc/newsyslog.conf and the files located in /etc/newsyslog.d/. I normally create a new, such as /etc/newsyslog.d/development.conf.
~$ sudo nano -w /etc/newsyslog.d/development.conf
Adding the following line(s).
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/Users/cableman/source//sites//logs/*.log 644 5 5120 * JG
As I don't want to go into this file every time I add a new site to my development server I use wildcards in the path as shown above. The first number set the permissions on the log files after rotation, namely read and write to the owner and read to any one else. The next two number tells newsyslog that I wants 5 rotations and that the file should first be rotate when its 5 Mb or lager. The asterisk simple tells newsyslog that I don't know or care about the PID file. The J tells it that I want to bzip2 rotated files and G that I'm using wildcards (*) in the path.
To verify that it works and simulate a rotation, you can run this command.
~$ newsyslog -nvv
If you want to perform the rotation right now simply run newsyslog without any parameters. OS X will automatically run the rotation together with all the other log files located on the system.
Comments
Tabs
Just whitespace
Questions
Add new comment