Take the 2-minute tour ×

My situation is that I want to rotate maillog of postfix anytime after my php script send the mail.
So that I can analyze log file, disapatch different error message to different sender and after that delete the rotated log file preventing original maillog from growing too large.
My Freebsd version is 8.0 release.
Is it possible that I don't have to install any extra program tool increasing difficulties in setting up system.
thanks in advance

share|improve this question
add comment

closed as off topic by X-Istence, user97693321, S.L. Barth, Linger, Sirko Nov 2 '12 at 13:14


2 Answers

up vote 0 down vote accepted

FreeBSD uses newsyslog(8) for its log rotation. It is configured by /etc/newsyslog.conf and by default uses a daily rotation for /var/log/maillog.

If really necessary you can trigger a non-scheduled rotation by calling newsyslog -F /var/log/maillog. But IMHO it is preferable not to and only to change the policy in newsyslog.conf because that a) requires no additional code and b) means that the config documents the system's state.

share|improve this answer
add comment

Couldn't logrotate be helpful to you? It's a rather standard tool for log rotation on nix systems.

If I were in your situation, I would use logrotate and write custom scripts to do what I want with the logs: since you don't express your needs in a precise way, it's hard to give precise answers.

When you say you want to use PHP for that, I hope for you that you don't mean "from within the web server", but "as a system script language". I would really not let the Apache PHP module, for instance, manipulate the system logs. I would ensure that they're out of its reach, actually.

Additionally, I think it might be a question for Server Fault or UNIX / Linux instead.

share|improve this answer
Yes you're right I write some php script and run with crontab every 5 min. Use shell_exec to call external program or shell to do log rotate is the only way that I can figure out. I find that there no "logrotate" commend after I install my freebsd. Only newsyslog and syslog that I can use. I mean that if it is possible to not to install logrotate or other non-default tool to rotate the log manually. –  inker Aug 31 '12 at 7:36
add comment
