Closed Thread Icon

Topic awaiting preservation: Cron Job Emails (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=28330" title="Pages that link to Topic awaiting preservation: Cron Job Emails (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Cron Job Emails <span class="small">(Page 1 of 1)</span>\

 
H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-13-2006 10:38

Just a quick question....

I have set up a cron job, and it is sending me an email every time it runs even if there are no errors.

I could swear earlier it was only sending emails if there was any error.



So what is the normal cron job behaviour, is there any way to get it to send only on error?

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana
Insane since: Aug 2000

posted posted 08-13-2006 18:41

What I'm remembering is that if your script creates any output to standard out or standard error, crond will send an e-mail. If you don't want to receive an e-mail when your cron runs, make sure your script doesn't produce any output.

I could be wrong, because I took a couple of minutes to read the man pages for cron (1), cron (5), and crond (8) and found no mention of when crond sends an e-mail.

.



-- not necessarily stoned... just beautiful.

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-14-2006 04:07

Yeh, i tried getting it to run a blank php script and still got the emails


Very annoying... i dont particularly want to recieve thousands of blank emails each day..

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-14-2006 09:24

* * * * * myCronJobExecutable >/dev/null

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-14-2006 09:57

But that stops all emails, even the error ones

I want it to email me when there is an error and not if it executes without an error. I would have thought that would be normal operation.

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-14-2006 17:49

Learn your shell, son

>/dev/null only redirects stdOut, not stdErr - which you would still get as an email.

kuckus
Paranoid (IV) Mad Librarian

From: Glieberlermany
Insane since: Dec 2001

posted posted 08-14-2006 17:58

It shouldn't, as ">" will redirect only standard output, "2>" only the error msgs, and "&>" both.

So if >/dev/null in fact stops all mails, perhaps the script doesn't properly declare the errors as such?


[ed.[^way too fast, that person]]

(Edited by kuckus on 08-14-2006 18:00)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-14-2006 20:07

yeah... 8 hours response time is *way* to fast ^^.

Btw, your php script shouldn't send an email if it outputs nothing.
Sure you don't have a stray newline behind the closing ?> or so?

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-15-2006 02:10

I tried >/dev/null and made it have an error but got no email TP.


I will check the php script maybe there is a newline, i wouldnt be suprised because im sure it was working differently before. Just couldnt find anyinfo on the normal behaviour of cron.


edit: Should have known, that was it! Since it was working originally. Thanks for the help all

(Edited by H][RO on 08-15-2006 02:22)

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 08-15-2006 09:59

well, the man pages are decent - but there are multiple of them which you might easily miss.

See, you say 'man cron'
man says 'Reformatting cron(8), please wait...'

Note that (8) there?
It's kind of a sub index.

The cron(8) man page says
"SEE ALSO
crontab(1), crontab(5)
"

so let's see.
man crontab gives us crontab (1),

'man 5 crontab'
gives us crontab(5) which is extensive and does contain samples.


But of course the redirection to anything (even /dev/null) is defined by the shell in question.
On a linux system usually /bin/sh which is /bin/bash in reality.
man bash is large though

so long,

->Tyberius Prime

H][RO
Paranoid (IV) Inmate

From: Australia
Insane since: Oct 2002

posted posted 08-15-2006 11:55

Lol i think i will have to do some googling to put your post into english, i am very much a cron noob, and fairly new to linux too!

« BackwardsOnwards »

Show Forum Drop Down Menu