|
Home > Archive > Unix administration > March 2006 > Re-Direct To Null In A CronTab?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re-Direct To Null In A CronTab?
|
|
|
| All:
I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redirect
the output of all cron jobs in root's tab to /dev/null, in an effort to
prevent cron from generating e-mails for each time it runs a job. I've tried
various methods, using the 2>&1 > /dev/null method, or a > /dev/null, to
no avail with some (but not all) programs.
Is there any surefire way to redirect all output to /dev/null, or simply
tell cron not to send e-mails for jobs? Is it possible to maybe change the
definition of the mailer program cron uses to something like /bin/false so
it doesn't occur, or do most cron implementations use a built-in mailer?
Thanks in advance for any / all replies.
/dmfh
----
__| |_ __ / _| |_ ____ __
dmfh @ / _` | ' \| _| ' \ _ / _\ \ /
\__,_|_|_|_|_| |_||_| (_) \__/_\_\
----
| |
| Hajo Ehlers 2006-03-13, 7:51 am |
|
DMFH wrote:
> All:
>
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redirect
> the output of all cron jobs in root's tab to /dev/null, in an effort to
> prevent cron from generating e-mails for each time it runs a job. I've tried
> various methods, using the 2>&1 > /dev/null method, or a > /dev/null, to
> no avail with some (but not all) programs.
> Is there any surefire way to redirect all output to /dev/null
>From my knowledge:
First redirect stdout then stderr - meaning :
MyJob >/dev/null 2>&1
hth
Hajo
| |
| Doug Freyburger 2006-03-13, 5:54 pm |
| DMFH wrote:
>
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redirect
> the output of all cron jobs in root's tab to /dev/null, in an effort to
> prevent cron from generating e-mails for each time it runs a job. I've tried
> various methods, using the 2>&1 > /dev/null method, or a > /dev/null, to
> no avail with some (but not all) programs.
command 2>&1 > /dev/null
will work for most but not all.
> Is there any surefire way to redirect all output to /dev/null, or simply
> tell cron not to send e-mails for jobs?
In general no. The problem is programs can open /dev/console
or /dev/tty explicitly in an attempt to get around IO redirections.
You will need to deal with each instance and fix them individually.
> Is it possible to maybe change the
> definition of the mailer program cron uses to something like /bin/false so
> it doesn't occur, or do most cron implementations use a built-in mailer?
This is the wrong solution to the right problem.
You WANT to get e-mail from failed cron jobs. You WANT to
be alerted to situations that change unexpectedly and effect
cron jobs.
The the individual problem - good. Break the design to avoid
fixing the individual problem - bad. So please post what your
actual problem is. Then folks can help fix that rather than
help break the design.
| |
|
| Doug Freyburger wrote:
>
> command 2>&1 > /dev/null
>
Doug,
I fairly certain that's the wrong way about. That will direct stderr to
stdout and then will direct stdout to null, leaving stderr directed to
stdout. I think what you meant and what the OP wanted is
command >/dev/null 2>&1
Which will redirect stdout to null and then also redirect stderr to null
Examples with no redirection, with your method and with mine...
john@oscar:~> ls rubbish
/bin/ls: rubbish: No such file or directory
john@oscar:~> ls rubbish 2>&1 >/dev/null
/bin/ls: rubbish: No such file or directory
john@oscar:~> ls rubbish >/dev/null 2>&1
john@oscar:~>
JohnK
| |
| Doug Freyburger 2006-03-13, 5:54 pm |
| JohnK wrote:
> Doug Freyburger wrote:
>
>
> Doug,
>
> I fairly certain that's the wrong way about. That will direct stderr to
> stdout and then will direct stdout to null, leaving stderr directed to
> stdout. I think what you meant and what the OP wanted is
>
> command >/dev/null 2>&1
>
> Which will redirect stdout to null and then also redirect stderr to null
Thanks for catching the typo. Good correction. If that typo was
the OP's problem, situation solved.
| |
| Barry Margolin 2006-03-13, 5:54 pm |
| In article <1142272366.013526.265170@i40g2000cwc.googlegroups.com>,
"Doug Freyburger" <dfreybur@yahoo.com> wrote:
> JohnK wrote:
>
> Thanks for catching the typo. Good correction. If that typo was
> the OP's problem, situation solved.
What typo? Looks like a misunderstanding, not a typo, to me. A typo is
when you get one or two characters wrong because you hit the wrong key,
not when you type whole words or expressions in the wrong order.
To any experienced shell scripter, '>/dev/null 2>&1' is a common idiom,
it's hard to see how they would get it backwards unless they didn't
realize that the order mattered.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| Doug Freyburger 2006-03-13, 5:54 pm |
| Barry Margolin wrote:
> Doug Freyburger wrote:
>
>
> What typo? Looks like a misunderstanding, not a typo, to me. A typo is
> when you get one or two characters wrong because you hit the wrong key,
> not when you type whole words or expressions in the wrong order.
Does spoonerism work as a better term? I think that's the
term for swapped words while speaking, don't know if it
maps to swapped word while typing.
> To any experienced shell scripter, '>/dev/null 2>&1' is a common idiom,
> it's hard to see how they would get it backwards unless they didn't
> realize that the order mattered.
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***
| |
| Michael Paoli 2006-03-15, 7:49 am |
| DMFH wrote:
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redirect
> the output of all cron jobs in root's tab to /dev/null, in an effort to
> prevent cron from generating e-mails for each time it runs a job. I've tried
> various methods, using the 2>&1 > /dev/null method, or a > /dev/null, to
> no avail with some (but not all) programs.
Have a look at:
http://www.weak.org/pipermail/buug/...une/002444.html
for some more information on redirection.
|
|
|
|
|