Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a service manifest on Solaris (Smart OS actually) and I would like to periodically clean its log files either automatically or manually without shutting down the server.

My log is here:


Is there a way to either clean this, limit its size, or move it?

share|improve this question
up vote 1 down vote accepted

I would use logadm to rotate the logs for you. On the latest base image (13.1.0) there is a default logadm entry for rotating SMF logs (check the /etc/logadm.conf file):

smf_logs -C 3 -c -s 1m /var/svc/log/*.log

That entry will rotate the SMF service logs whenever they hit 1m in size (-s 1m), only keep 3 versions after each rotation (-C 3) and rotate the log by copying the original log file then truncating it to zero (-c). The nice thing about the above is that it's a pattern based logadm definition, so you can run it manually with:

logadm smf_logs

There is a crontab entry (under the root user) on the base 13.1.0 image to run logadm once per hour.

10 * * * * /usr/sbin/logadm

An hourly cron is good for size based rotation and helps keep things in check if some logs tend to grow pretty quickly.

share|improve this answer
Thanks! Awesome detail. This is exactly what I needed :) Can you clarify the "10 * * * * /usr/sbin/logadm" How do I check what the cronjob is set at (frequency) and how do I change it? – Justin Cloud May 16 '13 at 6:10
That will run the /usr/sbin/logadm command every hour, at 10 minutes past the hour. man crontab and man cron – chorrell May 18 '13 at 0:25

You can do this by writing a script then create a cron job to run the script periodically.

share|improve this answer
Yes, but can I archive the file (or chop it head -n 5000) while the manifest is running and writing to the file? – Justin Cloud May 14 '13 at 6:43
If the file is being written to, you can't move the file. In that case, you need to copy the contents and then zero the file. – Jenny D May 14 '13 at 7:54
How do I zero a file being written to? – Justin Cloud May 14 '13 at 17:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.