Professional Web Applications Themes

Re-Direct To Null In A CronTab? - Linux / Unix Administration

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 ...

  1. #1

    Default 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 / _` | ' \| _| ' \ _ / _\ \ /
    \__,_|_|_|_|_| |_||_| (_) \__/_\_\
    ----
    DMFH Guest

  2. #2

    Default Re: Re-Direct To Null In A CronTab?


    DMFH wrote: 
     
    First redirect stdout then stderr - meaning :

    MyJob >/dev/null 2>&1

    hth
    Hajo

    Hajo Guest

  3. #3

    Default Re: Re-Direct To Null In A CronTab?

    DMFH wrote: 

    command 2>&1 > /dev/null

    will work for most but not all.
     

    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.
     

    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 Guest

  4. #4

    Default Re: Re-Direct To Null In A CronTab?

    Doug Freyburger wrote: 
    >
    > command 2>&1 > /dev/null
    >[/ref]

    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...

    johnoscar:~> ls rubbish
    /bin/ls: rubbish: No such file or directory

    johnoscar:~> ls rubbish 2>&1 >/dev/null
    /bin/ls: rubbish: No such file or directory

    johnoscar:~> ls rubbish >/dev/null 2>&1
    johnoscar:~>


    JohnK
    JohnK Guest

  5. #5

    Default Re: Re-Direct To Null In A CronTab?

    JohnK wrote: [/ref]

    >
    > 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[/ref]

    Thanks for catching the typo. Good correction. If that typo was
    the OP's problem, situation solved.

    Doug Guest

  6. #6

    Default Re: Re-Direct To Null In A CronTab?

    In article <googlegroups.com>,
    "Doug Freyburger" <com> 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[/ref]
    >
    > Thanks for catching the typo. Good correction. If that typo was
    > the OP's problem, situation solved.[/ref]

    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, 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 ***
    Barry Guest

  7. #7

    Default Re: Re-Direct To Null In A CronTab?

    Barry Margolin 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.[/ref]

    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.
     

    Doug Guest

  8. #8

    Default Re: Re-Direct To Null In A CronTab?

    DMFH wrote: 

    Have a look at:
    http://www.weak.org/pipermail/buug/2004-June/002444.html
    for some more information on redirection.

    Michael Guest

Similar Threads

  1. su and crontab
    By FrankNatoli in forum Linux / Unix Administration
    Replies: 8
    Last Post: November 29th, 05:49 PM
  2. Crontab
    By Antigoni in forum Linux / Unix Administration
    Replies: 2
    Last Post: June 4th, 12:15 PM
  3. crontab bug?
    By LeVA in forum Debian
    Replies: 1
    Last Post: August 4th, 12:10 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139