[comp.unix.wizards] CRON w/o logging

pjh@mccc.UUCP (Pete Holsberg) (08/15/88)

I recently asked for help with a problem on a 3b2/400 running SysV R3.1.2.
To wit, after a couple of days of norml operation, cron has stopped
writing to /usr/lib/cron/log.  Several people have suggested that the
file may be too big, and that I should check the ulimit.

The file is still less than 4096 bytes.  ulimit is 20480.  So I'm still
in need of help.

Incidentally, cron is still executing the crontab files -- it's just not
logging its actions.

Thanks.

Pete Holsberg                   UUCP: {...!rutgers!}princeton!mccc!pjh
Technology Division                   ...!att!jonlab!mccc!pjh
Mercer College			CompuServe: 70240,334
1200 Old Trenton Road           GEnie: PJHOLSBERG
Trenton, NJ 08690               Voice: 1-609-586-4800

dgy@sigmast.UUCP (Dave Yearke) (08/17/88)

In article <755@mccc.UUCP> pjh@mccc.UUCP (Pete Holsberg) writes:
>
>I recently asked for help with a problem on a 3b2/400 running SysV R3.1.2.
>To wit, after a couple of days of norml operation, cron has stopped
>writing to /usr/lib/cron/log.  Several people have suggested that the
>file may be too big, and that I should check the ulimit.

I had the same problem when we first got our 3b2/500.  The answer to my
problem turned out to be this:  I had a weekly script that renamed the
log file to Old-Log, and created an empty log file.  This confused cron,
because I believe it always has log open for write, and can't deal with
the file disappearing or being modified by anything other than itself.

Once I added code to stop cron, then rename the file and create a new one,
then restart cron, the problem disappeared.

-- 
		Dave Yearke, Sigma Systems Technology, Inc.
		   5813 Main St, Williamsville, NY 14221
		  ...!{sunybcs,ames!canisius}!sigmast!dgy

haugj@pigs.UUCP (Joe Bob Willie) (08/19/88)

In article <591@sigmast.UUCP> dgy@sigmast.UUCP (Dave Yearke) writes:
>I had the same problem when we first got our 3b2/500.  The answer to my
>problem turned out to be this:  I had a weekly script that renamed the
>log file to Old-Log, and created an empty log file.  This confused cron,
>because I believe it always has log open for write, and can't deal with
>the file disappearing or being modified by anything other than itself.

cron appears to have the file open for append at end of file, zeroing
the file seems to work just fine.  moving it is a bad idea, however.
so, i copy the file to a new location and then zero the current log file.

here is the crontab entry which pertains to maintaining the log file
itself:

57	23	*	*	*	cp /usr/lib/cron/log /usr/lib/cron/o.log ; date > /usr/lib/cron/log

and here are the first five lines of each to show how they look:

==> /usr/lib/cron/log <==
Thu Aug 18 00:57:01 EDT 1988
<  root 27418 c Wed Aug 17 23:57:01 1988
>  CMD: find /tmp ! -user root -atime +3 -exec rm {} \;
>  root 27421 c Thu Aug 18 00:00:00 1988
>  CMD: /usr/lib/sa/sa1 &

==> /usr/lib/cron/o.log <==
Wed Aug 17 00:57:00 EDT 1988
<  root 20251 c Tue Aug 16 23:57:00 1988
>  CMD: find /tmp ! -user root -atime +3 -exec rm {} \;
>  root 20254 c Wed Aug 17 00:00:00 1988
>  CMD: /usr/lib/sa/sa1 &

you don't have to put the date in there, i just find that it makes things
easier.
-- 
 jfh@rpp386.uucp	(The Beach Bum at The Big "D" Home for Wayward Hackers)
     "Never attribute to malice what is adequately explained by stupidity"
                -- Hanlon's Razor

jr@oglvee.UUCP (Jim Rosenberg) (08/19/88)

From article <755@mccc.UUCP>, by pjh@mccc.UUCP (Pete Holsberg):
> 
> I recently asked for help with a problem on a 3b2/400 running SysV R3.1.2.
> To wit, after a couple of days of norml operation, cron has stopped
> writing to /usr/lib/cron/log.  Several people have suggested that the
> file may be too big, and that I should check the ulimit.
> 
> The file is still less than 4096 bytes.  ulimit is 20480.  So I'm still
> in need of help.
> 
> Incidentally, cron is still executing the crontab files -- it's just not
> logging its actions.

Hullo Pete!!

I remember your original posting, but it had slipped into a recess in the
mental attic.  Then a funny thing:  the same thing happened on my system.
cron was apparently working, but writing to the log file had stopped.  This
happened on a day when I went on a cleanup rampage.  We have lots of disk
space, but are close to the limit of one tape, so I've been savoring the
luxury of single-reel full backups.  The other day we crossed the limit & I
decided to clean things up.  Yes, yes, netlanders, I know, I should be cleaning
various log files weekly (weakly?) out of cron, but well, um, you know how
it is.

/usr/lib/log/cron was getting pretty big, so I gave the heave-ho to everything
but the last week's worth by sed'ing off only the last week's stuff into a
new file, then doing an mv of the new file to /usr/lib/log/cron.  *SAME DAY*
is when cron stopped logging.  I puzzled over this, and then realized that
maybe it was not so smart to do this while the inode was still open!  Of
course an rm to an open file is quite legal in UNIX -- many programs use this
trick to make sure there are no temporary files hanging around.  If you've
done something to the log file while cron is still running, cron may be using
an inode that doesn't appear in any directory entry, so it sure won't show
up when you look at /usr/lib/cron/log.  How long since you rebooted?  What
are the perms on /usr/lib/cron/log -- could you or someone else have done
something to it during the lifetime of the current cron process?  Do you have
any scripts either executed out of cron or fired off by /etc/rc that clean
the log file while cron is running?

I gave cron the old SIGTERM (just kill <cron's_pid> with no signal number will
do nicely) and restarted cron from the shell.  Logging commenced forthwith
and hasn't burped since.

Dunno if this is your problem, but try bringing down cron and restarting it.
-- 
Jim Rosenberg                        pitt
Oglevee Computer Systems                 >--!amanue!oglvee!jr
151 Oglevee Lane                      cgh
Connellsville, PA 15425                                #include <disclaimer.h>