Operating System - HP-UX
1751726 Members
5784 Online
108781 Solutions
New Discussion юеВ

Re: Automatically "recreate" mail.log on reboot ?

 
SOLVED
Go to solution
Stuart Abramson_2
Honored Contributor

Automatically "recreate" mail.log on reboot ?

You know how a reboot moves /var/adm/syslog/syslog.log to "OLDsyslog.log" and creates a new "syslog.log"?

Can I set something up to do the same thing for "mail.log"?: move mail.log to OLDmail.log and create a new mail.log?

Is there some flag to do that?

Our "mail.log" files get so big that they become a problem. We don't trim them in cronjobs - what do you do?
12 REPLIES 12
Stuart Abramson_2
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

Please don't tell me how to clean up the mail.log. I know how to do that. I just want to know if I can set it up at reboot time, or should I do it in a cronjob...
Michael Schulte zur Sur
Honored Contributor
Solution

Re: Automatically "recreate" mail.log on reboot ?

Hi,

you find the procedure in:
/sbin/init.d/syslogd
You probably could do it, when the sendmail daemon is started.

Michael
Jean-Luc Oudart
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

The 1st solution implies it only happens when you reboot your server and therefore may not answer your mail.log size pb.

You may have to use cron
you can copy the file to different location (and gzip it)then reset with

> mail.log

Regards,
Jean-Luc
fiat lux
Jeff Schussele
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

Hi,

You'll have to add code to the /sbin/init.d/sendmail script - like


mv /var/adm/syslog/mail.log /var/adm/syslog/OLDmail.log

This is the way syslog startup does it.
NOTE: these scripts are fair game for overwrite on patch installs or upgrades.
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Sridhar Bhaskarla
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

Hi,

There isn't any script that will move mail.log file through startup. You can configure one that will do it for you. Make sure that script starts before syslogd script though by putting the links with lower number than syslogd in sbin/rc2.d directory.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Jeff Schussele
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

Oops forgot to add you'll have to touch mail.log after the mv or as syslogd does it
> /var/adm/syslog/mail.log

Later,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Michael Schulte zur Sur
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

Hi,

you will want to stop syslogd and then you can mv mail.log like syslog.log.

Michael
Stuart Abramson_2
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

It looks like the best place to put it is inside the "/sbin/init.d/syslogd" script, right after:

if [ -f /var/adm/syslog/syslog.log ]; then
mv /var/adm/syslog/syslog.log /var/adm/syslog/OLDsyslog.
log
mask=`umask`
umask 022
> /var/adm/syslog/syslog.log
umask $mask
fi

But, as someone pointed out above, we reboot some servers every other weekend, but some servers we NEVER reboot. So, I'll probably do a cronjob.

Thanks for your help...
Sridhar Bhaskarla
Honored Contributor

Re: Automatically "recreate" mail.log on reboot ?

To clarify a bit more sendmail and syslogd (may not be bad) scripts isn't an excellent place to put the code in due to

1. It could be overwritten. swinstalls won't overwrite /sbin/init.d/ files. But you may yourself replace it with a new version later.
2. syslogd that holds locks on this file starts before sendmail.

So, it's better to write a seperate script that starts before syslogd in my 2 cents opinion.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try