Re: /var/adm/lp/log keep on overwritten everyday (1418 Views)
Reply
Frequent Advisor
Shukor
Posts: 50
Registered: ‎05-06-2009
Message 1 of 5 (1,453 Views)

/var/adm/lp/log keep on overwritten everyday

Hi Gurus,

 

The OS is HPUX 11.31 and many printers are running on this critical server. The lp log is very important log for the application team to monitor the printing status. Recently we implemented daily log rotation and scheduled in crontab. 

 

The issue we having is everytime the copying process done at 9am everyday, the lp log size become small and only contains  first 100 lines (the rest of the line went missing).

 

Herewith the crontab and script, pls help giving me some light here...

 

crontab:

00 09 * * * /usr/local/bin/run-parts /etc/cron.daily >/dev/null 2>&1

 

/etc/cron.daily/root-daily-cron.cron script:

.

.

LOGFILE=/var/adm/lp/log

for LOG_FILE_ROTATE in $LOGFILE
do
if [ -f $LOG_FILE_ROTATE -a -s $LOG_FILE_ROTATE ]
then
COPY_FILE="$LOG_FILE_ROTATE.$DAY"
cp -p $LOG_FILE_ROTATE $COPY_FILE
cat /dev/null > $LOG_FILE_ROTATE
fi
done

.

.

# pwd
/var/adm/lp
# ls -lrt

-rw-r--r-- 1 lp lp 261 May 12 09:00 log.Sun
-rw-r--r-- 1 lp lp 1038 Jun 1 09:03 log.Sat
-rw-r--r-- 1 root sys 43399 Jun 2 09:00 log.start
-rw-r--r-- 1 lp lp 7703 Jun 3 09:03 log.Mon
-rw-r--r-- 1 lp lp 3523 Jun 4 09:02 log.Tue
-rw-r--r-- 1 lp lp 5135 Jun 5 09:02 log.Wed
-rw-r--r-- 1 lp lp 3767 Jun 6 09:02 log.Thu
-rw-r--r-- 1 lp lp 3717 Jun 6 21:18 oldlog
-rw-r--r-- 1 lp lp 2343 Jun 7 09:03 log.Fri
-rw-r--r-- 1 lp lp 1029324 Jun 7 10:54 log <-- this log becoming log.$DAY on the next day but most of the lines will missing..

 

Thank you in advance..

Please use plain text.
Honored Contributor
Matti_Kurkela
Posts: 6,271
Registered: ‎12-02-2001
Message 2 of 5 (1,435 Views)

Re: /var/adm/lp/log keep on overwritten everyday

Is there enough disk space for 2 copies of the /var/adm/lp/log to exist?

 

The script attepts to copy the current /var/adm/lp/log to /var/adm/lp/log.<day> before truncating /var/adm/lp/log.

If disk space is tight, it might be that it only can copy the first 100 lines or so before the disk becomes 100% full.

Because the script does not seem to have any error-checking at all, it won't notice this, and will truncate /var/adm/lp/log even if only part of it was successfully copied.

 

Note: if the system has been installed using HP-UX default LVM layout, then /var/adm/lp and /var/spool/lp are both using the space of the /var filesystem. If large print jobs are sent to the system at about 9am, they would be temporarily stored in /var/spool/lp before being sent to the printer, consuming the /var filesystem space. But after those print jobs are completed, the files in /var/spool/lp would be automatically deleted, giving the space back.

 

Please run "dmesg" and read the output. Does it include any messages about filesystems being full?

 

Also, please replace the ">/dev/null 2>&1" at the end of the cron job specification with something like ">/tmp/root-daily-cron.notices.txt 2>/tmp/root-daily-cron.errors.txt". Then let the job run once, and read at the /tmp/root-daily-cron.*.txt files. The messages in those files might make it easier to understand what the problem is.

MK
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,853
Registered: ‎03-06-2006
Message 3 of 5 (1,433 Views)

Re: /var/adm/lp/log keep on overwritten everyday

>cat /dev/null > $LOG_FILE_ROTATE

 

No need for evil cat.  Just use: > $LOG_FILE_ROTATE

 

>1029324 Jun 7 10:54 log <-- this log becoming log.$DAY on the next day but most of the lines will missing.

 

What's at the end of this large logfile?  Something from Jun 7?

Please use plain text.
Frequent Advisor
Shukor
Posts: 50
Registered: ‎05-06-2009
Message 4 of 5 (1,419 Views)

Re: /var/adm/lp/log keep on overwritten everyday

Hi Matti,

 

Disk space is not the root cause for this issue as there are plenty of free space and no disk full error in dmesg. But thank you for the good idea of replacing the ">/dev/null 2>&1" at the end of the cron job to the log file in the /tmp folder. Perhap I able to find something in this log file that maybe helpful in solving this issue..

 

Thanks..

Please use plain text.
Frequent Advisor
Shukor
Posts: 50
Registered: ‎05-06-2009
Message 5 of 5 (1,418 Views)

Re: /var/adm/lp/log keep on overwritten everyday

Hi Dennis,

 

Thank you for the reply. The active log file (log) is perfectly working fine as I can see it's updating the latest process at the end fo the file..but not in the copied log..hmmm..

 

root@gopgbl1: tail log
lkcfyp01-8811 indrajit lkcfyp01 Jun 9 03:19
Start: lkcfyp01-8811 Sun Jun 9 03:19:27 MAL 2013
End: lkcfyp01-8811 Sun Jun 9 03:19:27 MAL 2013
/etc/lp/interface/model.orig/lkcfyp01 tray3
/opt/hpnpl/bin/hpnpf -j lkcfyp01-8811+indrajit -a1 -x 23.220.4.21
lkcfyp01-8812 indrajit lkcfyp01 Jun 9 03:19
Start: lkcfyp01-8812 Sun Jun 9 03:19:38 MAL 2013
End: lkcfyp01-8812 Sun Jun 9 03:19:39 MAL 2013
/etc/lp/interface/model.orig/lkcfyp01 tray3
/opt/hpnpl/bin/hpnpf -j lkcfyp01-8812+indrajit -a1 -x 23.220.4.21

 

 

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation