Operating System - HP-UX
1748213 Members
3142 Online
108759 Solutions
New Discussion юеВ

Re: How to do log rotation in HP-UX?

 
SOLVED
Go to solution
senthil_kumar_1
Super Advisor

How to do log rotation in HP-UX?

I would like to log rotation for every month.

I knew that log will be rotated for every reboot, therefore one file with extention of .old will be created.

But I would like to log rotation for every month. So I need one log file for one month.
7 REPLIES 7
AnthonySN
Respected Contributor
Solution

Re: How to do log rotation in HP-UX?

James R. Ferguson
Acclaimed Contributor

Re: How to do log rotation in HP-UX?

Hi:

There is an old 'logrotate' utility at the HP-UX Porting Centre which you would have to compile yourself.

That said, you don't offer which HP-UX operating system versions you're using nor *which* logs you want kept monthly.

All this said, you could cruft a simple script (and schedule that from 'cron') that would call the standard startup/shutdown scripts like '/sbin/init.d/syslogd' to close and open a new logfile. Your script would then conclude its action by renaming the "OLD*" logfile to one with the month name.

Regards!

...JRF...
AnthonySN
Respected Contributor

Re: How to do log rotation in HP-UX?

>>But I would like to log rotation for every month. So I need one log file for one month.

creata a cron job to run every month to
restart the syslogd deamon by
/sbin/init.d/syslogd stop
/sbin/init.d/syslogd start
Raj D.
Honored Contributor

Re: How to do log rotation in HP-UX?

Senthil,

Check this out: Logrotate Management tool:
Logrotate is designed to ease administration of systems that generate large numbers of log files. It allows automatic rotation, compression, removal, and mailing of log files. Each log file may be handled daily, weekly, monthly, or when it grows too large.

http://hpux.connect.org.uk/hppd/hpux/Sysadmin/logrotate-2.5/

This is quite old tool, but you can try it out,







You can also find simple shell script or perl script that help to rotate the log:



Ex: (Change the logfile path for hp-ux to /var/adm/syslog/syslog.log )
------
## Configuration for logrotate
# Please read perl-logrotate.pl for more information

logfile /var/log/messages

rotate-time 1 week
keep-files 5
compress yes
status-file /var/cache/logrotate.status
dryrun yes
-------
Link:
http://freshmeat.net/projects/perl-logrotate/




Hth,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
P Muralidhar Kini
Honored Contributor

Re: How to do log rotation in HP-UX?

Hi Senthil,

You can schedule the log rotation to run based on your own schedule using cron.

Check the following link for more details -
* Syslog log rotation
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1230095

* Scheduling logrotate
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=382206

* logroate equivalent
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=799136

* Perl-Logrotate script
http://freshmeat.net/projects/perl-logrotate/

Hope this helps.

Regards,
Murali
Let There Be Rock - AC/DC
Kranti Mahmud
Honored Contributor

Re: How to do log rotation in HP-UX?

Kanagaraj
Regular Advisor

Re: How to do log rotation in HP-UX?

Senthil,
put cron job for every month begining

Take a backup of OLDsyslog.log file before restart syslog daemon
Cronjob entries below.

30 0 1 * * /usr/bin/mv /var/adm/syslog/OLDsyslog/log /var/adm/syslog/OLDsyslog/log1
32 0 1 * * /sbin/init.d/syslogd stop
33 0 1 * * /sbin/init.d/syslogd start