1833321 Members
2933 Online
110051 Solutions
New Discussion

Stop cron loggnig

 
SOLVED
Go to solution
KRI
Advisor

Stop cron loggnig

Hello !

How can I stop cron logging in HP-UX 11.00 ?

In Solaris systems I can modify /etc/default/cron from CRONLOG=YES to CRONLOG=NO.

Thx!
KRI
20 REPLIES 20
Anupam Anshu_1
Valued Contributor

Re: Stop cron loggnig

To stop cron:

/sbin/init.d/cron stop

To start Cron jobs:

/sbin/init.d/cron start

Hope this helps,

Anshu
KRI
Advisor

Re: Stop cron loggnig

:-)

I can't stop cron jobs !
I can stop cron logging to /var/adm/cron/log file.

KRI
Joseph Loo
Honored Contributor

Re: Stop cron loggnig

hi,

if i understand u correctly, u want the jobs to continue running but not to log at all? i am guessing, maybe because u have a lot of jobs running, say, every minute?

please note that /var/adm/cron/log is meant as a audit/accounting file to track that jobs are "fire" and stopping it from logging may not be desirable to the auditor. morever, i believe /var should always be quite large.

for now, i know the only way to not log is if you have no schedule jobs.

regards.
what you do not see does not mean you should not believe
twang
Honored Contributor

Re: Stop cron loggnig

In one of my machines, I have to run a SQL job every half hour. I have the same problem. To resolve this, I schedule another cron job to clean the /var/adm/cron/log everyday:
45 0 * * * > /var/adm/cron/log
KRI
Advisor

Re: Stop cron loggnig

Joseph,
thx for your replay !

You correctly understand me. I want to run cron jobs, but not to log at all. Yes, i have a lot of jobs, and log file /var/adm/cron/log grows very fast.

I want to stop cron from logging.

In Solaris it is possible.

KRI
Elmar P. Kolkman
Honored Contributor
Solution

Re: Stop cron loggnig

A solution might be to create an extra cron job that cleans or rotates the log file. Or replace the file with a symbolic link to /dev/null.

I would go for the first option. This way you can still find jobs that fail through the logfile(s), but you're filesystem will not fill up too fast with logging info.

Good luck,
Elmar

Every problem has at least one solution. Only some solutions are harder to find.
Sanjay Kumar Suri
Honored Contributor

Re: Stop cron loggnig

There seems to be no option in /etc/rc.config.d/cron to disable the logging behavior of cron except start/stop of cron.

The disabling of log can be achieved as suggested in previous post.

sks
A rigid mind is very sure, but often wrong. A flexible mind is generally unsure, but often right.
Anupam Anshu_1
Valued Contributor

Re: Stop cron loggnig

As such its not possible on HP-UX. However, you can have a job which nullifies the file regularly.

# echo > /var/adm/cron/log

Hope this helps,

Anshu

PS: I understand this is not exactly what you are looking for, rather its just a work around.
malay boy
Trusted Contributor

Re: Stop cron loggnig

Kri,
We have the same problem.But we choose to wrote another cronjob to wipe out the cron log every day at 00:00 am.

regards
mB
There are three person in my team-Me ,myself and I.
Rajesh D L
Frequent Advisor

Re: Stop cron loggnig

Hi,

You can have one more cron job to clear /var/adm/cron/log, may be every minute depending on the frequency of log file generation.

regards,
RDL.
KRI
Advisor

Re: Stop cron loggnig

Thx to all !

Good idea for me is to replace the log file with a symbolic link to /dev/null

Thank you Elmar !

Best regards!
KRI
Jose Mosquera
Honored Contributor

Re: Stop cron loggnig

Hi,

A way could be redirect the standar an error ouputs to a /dev/null for each task in the cronfile, i.e:

00 02 * * * /any_path/your_task >/dev/null 2>/dev/null


Rgds.
KRI
Advisor

Re: Stop cron loggnig

Jose !

It is not good way.
Cron log contains:
> CMD: /my_path/to_run.sh >/dev/null 2>&1
> root 2951 c Tue May 18 17:40:00 METDST 2004

KRI
Thierry Poels_1
Honored Contributor

Re: Stop cron loggnig

hi,

linking /var/adm/cron/log to /dev/null is an option for disabling logging completely (I wonder however what happens if cron is stopped and restarted : logfile is renamed and a new one is created).
But this leaves you with no possibility for troubleshooting nor auditing! It's no use to turn logging on AFTER you're in trouble, you have to do this BEFORE. Remember the cron log logs also batch and at-jobs, next to cron jobs.

Have a look at log rotation tools like "newsyslog" which allow you to control the size of log files and keep "older" logs in compressed format.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Thierry Poels_1
Honored Contributor

Re: Stop cron loggnig

hi,

as said I was curious how "/sbin/init.d/cron start" would handle a link to /dev/null...
Things seem to be going well, /sbin/init.d/cron checks if <> log exists and then moves it to OLDlog, as a symbolic link is not a plain file, no move is done and the link remains.

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Jose Mosquera
Honored Contributor

Re: Stop cron loggnig

Kri,

I'm not sure about your answer but my hint works fine in my box using the *exact* sintax posted.

Rgds.
Elmar P. Kolkman
Honored Contributor

Re: Stop cron loggnig

Thierry,

The problem with your solution is that it doesn't solve the problem. It will only result in no mails to the user, but in the cron logging there is no logging of the output of commands but logging from cron itself, reporting what it starts, at which time and when it stops with what exit code. So three lines per command that's being started.

Hope this explains it.
Every problem has at least one solution. Only some solutions are harder to find.
Thierry Poels_1
Honored Contributor

Re: Stop cron loggnig

mixing up names?
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Elmar P. Kolkman
Honored Contributor

Re: Stop cron loggnig

Oops... Sorry, Thierry... Meant Jose, of course.
Every problem has at least one solution. Only some solutions are harder to find.
Jose Mosquera
Honored Contributor

Re: Stop cron loggnig

Hi pals,

My suggestion doesn't really avoid logging action into /var/adm/cron/log file. In fact, the Thierry's solution looks fine.

Best regards and excuse me the nuisances.