Operating System - HP-UX
1819928 Members
3054 Online
109607 Solutions
New Discussion юеВ

strange shell script problem...

 
amonamon
Regular Advisor

strange shell script problem...

I have 3 files on my system /UNIX/ and those are files for writing logs into them..
first it writes in one log info1.log and then writes to secong info2.log and then into 3rd.

I wanto to save that logs..becouse once it reaches something like: ~40485796 bytes it starts writeing into second log..then once ir reaches ~40485796 bytes file size it goes to third..

problem is that once it is finished with 3rd log it goes to 1st log and erase old data..I want to keep all those data..

any help?
7 REPLIES 7
V. Nyga
Honored Contributor

Re: strange shell script problem...

Hi,

it seems to be a simple, good working 'logrotation'.
You could make a manuell copy of the files that already have reached ~40485796 bytes.

If you want to make this automatically maybe this will help you:
http://hpux.ee.ualberta.ca/hppd/hpux/Sysadmin/logrotate-2.5/

HTH
Volkmar
*** Say 'Thanks' with Kudos ***
amonamon
Regular Advisor

Re: strange shell script problem...

it does rotate logs by itself..but I just want to have all those logs in one big daily log..
Apai
Occasional Advisor

Re: strange shell script problem...

hi amonamon ,

maybe you can do this at end of line in the third files.

cat info2.log >> info1.log;cat info3.log >> info1.log

This will make all the log writes to info1.log

And, Since the logs files are pretty big , i suggest you derived input for info2.log and info3.log.

hope this helps
Rasheed Tamton
Honored Contributor

Re: strange shell script problem...

Check your script and if there is a line called find /dirname -size 40485796c change it to four times bigger than 40485796. So you will have bigger log size.

Other way is to make another script on cron the logic of which should be to copy and compress the first two log files once the third one is started.
V. Nyga
Honored Contributor

Re: strange shell script problem...

Hi again,

how long does it last to create one log?
I thought about some weeks or months, so you've enough time to copy it!
Your log flies are about 40 MB, this is already a big log file, more would be much more unclear to check.
With the link I gave you, you can define when a file will be copied, so you can make copies to keep those data.

V.
*** Say 'Thanks' with Kudos ***
drb_1
Occasional Advisor

Re: strange shell script problem...

Sounds like a working syslog.

When memory was more expensive,
and archiving required human intervention
(e.g. mounting a tape),
this was a convention for archiving mail streams and other queues.

o Maintain 3 logs.
o Reuse the oldest of 3 logfiles.
o Archive the middle of the 3 logfiles.
o Notify the operator to change tapes.

This could theoretically be done with 2 logfiles (active + standby),
but using 3 allowed backup to a slow archive mechanism before a double-high spike in activity exceeded the latest log size.

ksh> TARD=/var/adm/logarchived
ksh> GLOB=/var/adm/logrotate*
ksh> find $GLOB \
> -newer $(ls -t1 "$TARD"|tail +2|head -1) \
> -exec tar {} ';' \
> -exec echo change tape '|' mail wheel ';'
ksh> # operator changes tape and then
ksh> touch "$TARD"

Note that there are no quotes around $GLOB
in the find command.



The find command can be placed in a daily/weekly/... crontab.
The size limit was usually set by the archive media.
The number of logs was set by tradeoff between log memory available and tolerance for spikeness in log growth rate.

The find command triggers when the middle file becomes newer than the last archive acknowledgement,
but must wait until the tar device is available.


Hopefully helpful,
Tor-Arne Nostdal
Trusted Contributor

Re: strange shell script problem...

There is several ways to concatenate the files or create one "big-file"
(commands like cat, tail -f etc. see attachment) but this might make it all more messy.

Initially you should check if log rotation and size is configurable in the application/program that generates the logfiles.

Perhaps you easily can select to disable the log rotation and/or put a more reasonable size for your system.

If you disable logrotation you must ensure to have cleanup routines to avoid running out of diskspace.

/Tor-Arne
I'm trying to become President of the state I'm in...