1

In most GNU/Linux distributions the default is to log start (and many different events) of every cron job to syslog. It's rather convenient, but not for a very frequent jobs, which started, say, every 1 minute.

I know how to redirect all cron jobs events to a different log via /etc/rsyslog.conf (*.*;cron,auth,authpriv.none -/var/log/syslog) and it's easy to heavily restrict the logging to, say, just error events via /etc/default/cron (EXTRA_OPTS="-L 4"). But this affect all of cron jobs.

What if I want to restrict the logging of certain cron jobs (said frequent every-1-minute jobs)? Is it possible to set this up via /etc/rsyslog.conf or in /etc/crontab itself? The system is Debian 8.0 Jessie.

1 Answer 1

0

IMHO not possible via config files because that, as you say, would affect all cron jobs for the user.

However it's possible to forcefully redirect just the stdout output or both stdout and stderr of specific cron jobs like this:

* * * * * cron_cmdline_job1 >> /<path>/cron_job1.stdout.log
* * * * * cron_cmdline_job2 >>& /<path>/cron_job2.stdout_stderr.log

The advantage of redirecting just stdout would be that you'd immediately get and email with the stderr content when the job ends (if that's your preference, can equally well be seen as a disadvantage).

If such logs are of no interest then you can direct to /dev/null instead, of course.

2
  • The question is not how to redirect output of cron jobs, but how to disable the cron service from logging that these cron jobs has been started. This is annoying for every-minute jobs. Jun 1, 2015 at 7:58
  • 1
    I see. I don't think you can since there is no logging-related env var or other knob that you can selectively apply to individual job entries inside the crontab file. Jun 1, 2015 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.