 |
|
 |
|
|
 |
Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 07:48 AM
All:
I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redire
ct
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 @ / _` | ' \| _| ' \ _ / _\ \ /
\__,_|_|_|_|_| |_||_| (_) \__/_\_\
----
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 12:51 PM
DMFH wrote:
> All:
>
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redi
rect
> 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 tri
ed
> 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
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 10:54 PM
DMFH wrote:
>
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redi
rect
> 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 tri
ed
> 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.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 10:54 PM
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
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 10: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.
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 10: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 ***
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-13-06 10: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 ***
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
 |
Re: Re-Direct To Null In A CronTab? |
 |
 |
|
|
03-15-06 12:49 PM
DMFH wrote:
> I run OpenBSD V3.7 on Sparc 4M & 4C class machines, and I'm trying to redi
rect
> 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 tri
ed
> 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.
[ Post a follow-up to this message ]
|
|
|
 |
|
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 09:48 PM. |
 |
|
|
 |
|
 |
|
|
 |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
|
|
|
|
Medical and Health forum | Computer Games Reviews | Graphics design forum
|
 |
|
 |
|