1848038 Members
2615 Online
104022 Solutions
New Discussion

Re: Clearing mail.log

 
vignes_1
New Member

Clearing mail.log

Hi,

My system's /var/adm/syslog/mail.log file was large and I just cleared it with : >mail.log. Is this the correct way to clear system log files? do I need to stop the mail daemon before clearing the log file ... I noticed the file is not updated since i cleared, it's still empty. I wonder if these files can be cleared while the process are still running. Any advice.........
7 REPLIES 7
Court Campbell
Honored Contributor

Re: Clearing mail.log

after you chicken lip ">" then send a HUP signal to sendmail.

# kill -HUP

My suggestion would be to copy mail.log to another location. archive it and then chicken lip the file and send a HUP.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Basheer_2
Trusted Contributor

Re: Clearing mail.log

I usually copy this to another file, then vi the file and remove 90% of it.
Fat Scrape
Honored Contributor

Re: Clearing mail.log

Hi Vignes,

if you decide to clear mail.log remember that this file is locked by syslogd and not by sendmail.

If you check /etc/syslog.conf file you see that mail.log is managed by syslogd.

This test in my machine:

fuser /var/adm/syslog/mail.log
/var/adm/syslog/mail.log: 584o

ps -ef |grep 584
root 584 1 0 Dec 5 ? 0:10 /usr/sbin/syslogd -D

This means that /var/adm/syslog/mail.log is in open state by syslogd daemon.

Following this step to clear mail.log:
cd /var/adm/syslog
/sbin/init.d/syslogd stop
mv mail.log mail.log.old
touch mail.log
/sbin/init.d/syslogd start

If you want to do every time mail.log grow bigger then bytes you can use logrotate utility.

Regards,

Fat
Court Campbell
Honored Contributor

Re: Clearing mail.log

Nice catch Fat Scrape. I wasn't thinking about syslogd, but you can always HUP that too.

# kill -HUP
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
MarkSyder
Honored Contributor

Re: Clearing mail.log

Try SAM -> routine tasks -> system log files. Trim the mail.log file to the recommended size. This will empty the file and create a file called mail.logSAMTRM.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Anshumali
Esteemed Contributor

Re: Clearing mail.log

apart from what is asked for...you can use logroate. This trims and manages the logfiles on system.
Search on the forum. May be a fit in your requirement.
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
SSCHAER
Advisor

Re: Clearing mail.log

tail -500 mail.log >mail.wrk
cat mail.wrk >mail.log
rm mail.wrk


used to work on 11.00 l-class servers