Operating System - HP-UX
1752720 Members
5647 Online
108789 Solutions
New Discussion

Re: Script to backup log file and open new log file

 
Doug O'Leary
Honored Contributor

Re: Script to backup log file and open new log file

Hey;

You need a fi at the end of your script...

if [ test condtion ]
then
...
fi

HTH

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
Jeff_Traigle
Honored Contributor

Re: Script to backup log file and open new log file

Actually, for open log files, it's better to mv, not cp. That way the process that has it open can continue writing to it. You can then touch a new file with the original name, if necessary, and then restart the process so it starts using the new file. This is exactly what logrotate does when you use the "create" option. If you cp the file and the null the original, you potentially lose data.

I've been playing with logrotate on an HP-UX system. I was disappointed by the version at the Porting Center. It doesn't have as many of the options as the latest versions available as source from http://packages.qa.debian.org/l/logrotate.html, but if you have no way to compile (or don't want to bother with compiling), it'll do the basics well enough.
--
Jeff Traigle