Cron log file trimming

Cron log file trimming

Post by Frank DeBolt, Jr » Sat, 26 Jul 1997 04:00:00




> Solaris 2.5.1:

> Sometime back, I asked about ways to trim the log that cron produces.
> I have a
> script that renames the /var/cron/log file periodically but cron
> continue to
> write into the renamed file.

Try:
    cp /var/cron/log /var/cron/log.old; cp /dev/null /var/cron/log

Or turn off the log by editing /etc/default/cron.  All the log tells you
is whether or not
cron ran successfully every minute, nothing about the status of the
individual jobs.

--
Frank DeBolt, Jr.               |  Any sufficiently advanced technology
Rock Hill, South Carolina       |      is indistinguishable from magic.

 
 
 

Cron log file trimming

Post by Andy Harp » Sat, 26 Jul 1997 04:00:00


Solaris 2.5.1:

Sometime back, I asked about ways to trim the log that cron produces. I have a
script that renames the /var/cron/log file periodically but cron continue to
write into the renamed file.

One respondent noted that this is because cron keeps the file open all the
time; another noted that cron might accept a HUP signal to reset. Well HUP
doesn't work so, other than killing and restarting cron (which would likely be
a bit dicey via a cron job) it seems that there's no sensible way to handle
this.

In passing, I noted there's a 'logchecker' script which attempts to trim
the cron log if it exceeds the system size limit. This suffers from two flaws:
  * It also doesn't tell cron to start writing the new log so its not actually
    very helpful as a means of t* log files.

  * It works only if size limits are defined (we dont use them yet).

To sum up then, t* the cron log file would appear to be impossible to
handle without stopping/starting cron completely, or via a reboot. I feel this
is very unsatisfactory as I want to track what cron does but do not want itb
filling up my disk. Any other suggestions would be gratefully received..

Thanks

Andy Harper
Kings College London

 
 
 

Cron log file trimming

Post by Frank D. Cring » Sat, 26 Jul 1997 04:00:00



>In passing, I noted there's a 'logchecker' script which attempts to
>trim the cron log if it exceeds the system size limit. This suffers
>from two flaws:
>  * It also doesn't tell cron to start writing the new log so its not
>    actually very helpful as a means of t* log files.

It copies the current contents into /var/cron/olog and then truncates
/var/cron/log to zero length.  Other than possibly losing a few lines
between the copy and the truncation, this does what you want.

Quote:>  * It works only if size limits are defined (we dont use them yet).

Just make your own local version of /etc/cron.d/logchecker with a
hardwired limit.

--

voice: (+49 2304) 467101; fax: 943357

 
 
 

Cron log file trimming

Post by mi.. » Mon, 28 Jul 1997 04:00:00



Quote:>To sum up then, t* the cron log file would appear to be impossible to
>handle without stopping/starting cron completely, or via a reboot. I feel this
>is very unsatisfactory as I want to track what cron does but do not want itb
>filling up my disk. Any other suggestions would be gratefully received..

Putting...

        CRONLOG=NO

in /etc/default/cron has mostly solved the problem for me.  It still
logs serious errors there, but no longer logs the invocation of each
cron command.

--
-Gary Mills-    -Unix Support-    -U of M Academic Computing and Networking-

 
 
 

Cron log file trimming

Post by Tony Walto » Tue, 29 Jul 1997 04:00:00


<snip>

Quote:> All the log tells you
> is whether or not
> cron ran successfully every minute, nothing about the status of the
> individual jobs.

This is not true.  If a job exits with a nonzero return code this is
shown in the cron log.  For example if I try to run a cron job to cat
the nonexistent file /foobar I see

Quote:>  CMD: cat /foobar
>  tonyw 16497 c Mon Jul 28 11:33:00 1997

<  tonyw 16497 c Mon Jul 28 11:33:00 1997 rc=2

The rc=2 is the job's return status.  2 is ENOENT ("no such file or
directory") in /usr/include/sys/errno.h

So I know not only that the job failed, but why...

Regards

Tony

 
 
 

1. Trimming log files and cron

Hi:

I have an entry in my crontab file that looks like this:

34 02 * * * root find /var/log/messages -size +32 -exec /bin/mail -s
"{}"  root < /var/log/messages \; -exec cp /dev/null {} \;

Now, I can follow most of this, but I don't see how this entry
actually trims the messages log.  Can someone enlighten me.

Thanks

John Riggs

2. Linux desktop fades when surfing

3. Help: Cron - trim a file daily

4. changing argv for ps

5. Re\: Help\: Cron - trim a file daily

6. Release -0.79 of SmallEiffel The GNU Eiffel Compiler

7. Trimming UNIX Log Files

8. U-FTPD: 530 Login incorrect

9. Scripts for Log File Trimming ?

10. Trimming log files with no loss of data

11. trimming a log file with a certain size

12. trimming log files, or getting any at all!

13. cron.deny and cron.allow files for CRON management