[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: cron emailing user
- From: "Tyler Nally" <tnally iquest net>
- To: <redhat-install-list redhat com>
- Subject: Re: cron emailing user
- Date: Tue, 4 May 1999 10:45:46 -0500
If there is "standard output" that is produced by cron that's
not captured into a file.... the default of cron is to e-mail it
to the owner of the cron command being executed. If you don't
want e-mail everytime cron is executed, then you should make sure
in your shell script (or program) that all output is redirected
into a file ... all standard out should go into one file and
standard error should go into another....
Cron might look like this...
0 0 * * * cd /home/jason ; ./someshellscript.sh > shell.out 2>shell.err
Or ... if you do a cron like this....
0 0 * * * cd /home/jason ; ./someshellscript.sh
make sure in *someshellscript.sh* that the output automagically
goes to the two files.... I'd normally check for their existance
before and then erase them before putting output into them...
---------------------beginning of example script-----------------
:
cd /home/jason
if [ -s "shell.out" ]
then
rm shell.out
fi
if [ -s "shell.err" ]
then
rm shell.err
fi
echo "##---if you need to echo things into the file" > shell.out
echo "##---you can do it this way " >> shell.out
whatevercommandyouwanttorun >> shell.out 2>shell.err
----------------------end of example script---------------------------
Notice that in the example above, I test for the existence of
shell.out, if so then it's deleted so that when I start *echoing*
into it, the first time I want to put something in there I create
it with the '>' symbol for redirection of output/create file. Then
everytime after that I use the '>>' symbol for recirection of output/
append to an existing file.
Eitherway, the output from the shell script executed will never find
it's way back out to standard output or standard error which would
cause an automatic piece of e-mail to be delivered to your e-mail box.
Tyler
-----Original Message-----
From: Jason Ostrom <jason_ostrom ins com>
To: redhatinstalllist <redhat-install-list redhat com>
Date: Tuesday, May 04, 1999 9:34 AM
Subject: cron emailing user
>I have a quick question which may be outside the scope of this mailing list.
>If it is, please let me know a better mailing list.
>
>I have installed REdhat 5.2 and setup a crontab under my username to ping
>out every few minutes. Problem is that cron run by root emails my username,
>so that by the end of the day I have 300 emails. I have read the MANual
>pages and tried changing the MAILTO= environment, but don't think I am
>getting the right place. Any suggestions? I don't want cron emailing me
>everytime it runs my crontab.
>
>Jason P. Ostrom
>----------------------------------------------------------
>Network Systems Engineer
>International Network Services
>14160 Dallas Parkway, Suite 200
>Dallas, TX 75240
>Phone: (972)392-3545 x239
>Fax: (972)392-2381
>----------------------------------------------------------
>
>
>--
> PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
> http://www.redhat.com http://archive.redhat.com
> To unsubscribe: mail redhat-install-list-request redhat com with
> "unsubscribe" as the Subject.
>
>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]