Basic redirect question: stderr to /dev/null in cron job

Basic redirect question: stderr to /dev/null in cron job

Post by Bosc » Sun, 16 Nov 1997 04:00:00



Given the following crontab entries, why is stderr from the script
"monitor" still going to the console?
#=================================================================
11,31,44 16-6 * * 4-0 /usr/sbin/perf/pmr/monitor 300 > /dev/null 2>&1
&
11,31,44 16-6 * * 1-3 /usr/sbin/perf/pmr/monitor 300 > /dev/null 2>&1
&
9,17,38 3,7,11,15 * * 2,4 /usr/sbin/perf/pmr/monitor 300 > /dev/null
2>&1 &
9,17,38 4,8,12,16 * * 1,3,5 /usr/sbin/perf/pmr/monitor 300 > /dev/null
2>&1 &
#=================================================================
How can I ensure that stdout _and_ stderr are both redirected to
/dev/null, and that the ksh script "monitor" runs in the background
correctly?

Thanks,
Bosco

 
 
 

Basic redirect question: stderr to /dev/null in cron job

Post by R Robe » Tue, 18 Nov 1997 04:00:00



>Given the following crontab entries, why is stderr from the script
>"monitor" still going to the console?
>#=================================================================
>11,31,44 16-6 * * 4-0 /usr/sbin/perf/pmr/monitor 300 > /dev/null 2>&1
>&
>11,31,44 16-6 * * 1-3 /usr/sbin/perf/pmr/monitor 300 > /dev/null 2>&1
>&
>9,17,38 3,7,11,15 * * 2,4 /usr/sbin/perf/pmr/monitor 300 > /dev/null
>2>&1 &
>9,17,38 4,8,12,16 * * 1,3,5 /usr/sbin/perf/pmr/monitor 300 > /dev/null
>2>&1 &
>#=================================================================
>How can I ensure that stdout _and_ stderr are both redirected to
>/dev/null, and that the ksh script "monitor" runs in the background
>correctly?

>Thanks,
>Bosco

What you have does redirect standout out and standard in.  Be aware that cron
usually executes its jobs in the Bourne shell.  The problem apparently is in
the contents of your scripts. If you're really getting console output, then
one or more of the commands in the script is writing to /dev/console, not to
standard output.  Standard output of a cron script is, I believe, not defined,
but in some systems is caught and mailed to the owner.

You'd have to share more symptoms of what you mean by not "running in the
background correctly" if you want comments on that.  It's kind of unusual to
run a cron script in the background, as you're doing.  If it's supposed to be
a background process, set it up as a daemon.

Ray Robert
Three Star Software, Inc.
(503) 643-0774
FAX   526-0934


 
 
 

1. How do I redirect cron job output to /dev/null ?

Hi there,

I've got a program I'd like to run from cron which recursively deletes
old emacs autosave files (foo~) or whatever filename matches a regexp.
If you run the program from the prompt, you have to watch all of the
info scroll by about which directories are visited and which files are
axed.  Not particularly interesting to me, so I redirected this output to
/dev/null.  

I recently decided to move this job over to cron so that it would be done
more often than I remember to.  The trouble is, I can't get cron to stop
mailing me the output from the job!  I've tried
foo > /dev/null
foo >!& /dev/null
foo >! /dev/null
only #1 worked, but it still sends me mail with the output.

Any hints?
Eric Friedman

2. Solaris 8 and Apache 2.0.43

3. csh - trap std out and redirect stderr to /dev/null

4. Linux Emulation question

5. redirecting stdout,stderr and stdin to /dev/null

6. Mouse wheel

7. C-shell :: redirecting stderr to /dev/null

8. AIX fork() problems

9. redirecting cron error output to /dev/null

10. redirect sound card redirected to /dev/null

11. HELP: 2>&1 > /dev/null != 2>&- > /dev/null ???

12. redirect stdout and stderr to file (append) - basic stuff?

13. cp /dev/null or cat /dev/null