1836104 Members
3415 Online
110089 Solutions
New Discussion

Cron and syslog

 
Pippo_9
Frequent Advisor

Cron and syslog

Hi folks.

Is there a way to re-direct messages of cron to syslog.log? I know that messages of cron are logged in cron.log, but I would have them recorded also into syslog.log.

Any hints?

Thanks

Juan
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: Cron and syslog

Hi Juan,

YOu can get messages into syslog.log by through either a facility configured in syslog.conf or by the API command logger. I don't think you can redirect cron's messages by either of them. Ofcourse, you can write a script the checks cron's log and appends the new messages to syslog by logger command.

One way is to link /var/adm/cron/log to syslog.log but I haven't tried that.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Graham Cameron_1
Honored Contributor

Re: Cron and syslog

The man page for cron doesn't give any options for relocating the log file.
I don't think it will be easy to have cron activity also copied to syslog, but you could potentially write scripts to merge the 2 files periodically.

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Steven E. Protter
Exalted Contributor

Re: Cron and syslog

You obviously could redirect cron job output anyway you want.

You can redirect the output >> to /var/adm/syslog/syslog.log

What we actually do is direct the messages as email to a folder on our exchange server

example:

10 1 * * * jobname 2>&1 mailx -s "job output" someaddress@your.net

This collects the output nicely.

I have too much cron output to put it in syslog.

Just another idea.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Pippo_9
Frequent Advisor

Re: Cron and syslog

Sridhar,

I have tried with logger on 11.i and it works, unfortunately on 10.20 cron is not recognized as a facility (msg "unknown facility name").

Thanks for your help
Chris Wilshaw
Honored Contributor

Re: Cron and syslog

The ability to direct cron messages was added to syslogd in 11i (in patch PHCO_23413 I believe)

Looking at the man page (man 3c syslog), there is an entry for LOG_CRON if this is enabled.

This means that if that patch is installed on your system, you can add the entry

cron.* /var/adm/syslog/syslog.log

to /etc/syslog.conf. If you then restart syslogd, this should start to put cron messages into syslog.