Live data from Hacker News

Cronic - A cure for Cron's chronic email problem

habilis.net

21–30 of 47 posts

Re: Cronic - A cure for Cron's chronic email problem

#21
Writing programs like this must be a rite of passage. About a year ago I wrote one (https://github.com/mlaiosa/cronwrap). One day when I googled "cronwrap" to try to find the github page, there was a gazillion hits of other programs that also did the same thing. I looked at a couple and I still like mine more - but I also have a moderate case of not-invented-here syndrome.

Re: Cronic - A cure for Cron's chronic email problem

#22

Since this is hackernews, can someone explain the rational behind putting the 2>&1 after the > ? I know it works, but this reads to me: command > file.txt 2>&1 "write the output of command to file.txt and then map the error output to stdout" It makes so much more sense to write: command 2>&1 > file.txt There is clearly something in my brain that is confused about how redirection works.

Siblings have already responded to this well, so I'll just add an example:

  $ ls x
  ls: cannot access x: No such file or directory
  $ ls x >/dev/null 2>&1
  $ ls x 2>&1 >/dev/null
  ls: cannot access x: No such file or directory
The first command shows us trying to list a non-existent file, raising an error. The second sends stderr to stdout before sending stdout to null, suppressing all output. The third sends the error to stdout; any output on stdout would have been suppressed (can you come up with a way to verify this?)

Re: Cronic - A cure for Cron's chronic email problem

#23
There are more "fixes" for cron than I can count. I interpret this more as a fundamental misunderstanding of unix utilities and standards.

Utilities should not print out anything that the user can safely ignore. If you want to print out more info, add a VERBOSE mode (-v or -vv ...).

Re: Cronic - A cure for Cron's chronic email problem

#24
post #8

I have this problem, I only want to be emailed upon failure. However, the crontab of the account is shared by several different jobs run by different people, and I don't have control over that. Perhaps I could set the email in the crontab line? * * * * * MAILTO=me@example.com blahscript.sh

    blahscript.sh | mail -s "Subject" me@example.com

Re: Cronic - A cure for Cron's chronic email problem

#25
post #21

Writing programs like this must be a rite of passage. About a year ago I wrote one ( https://github.com/mlaiosa/cronwrap ). One day when I googled "cronwrap" to try to find the github page, there was a gazillion hits of other programs that also did the same thing. I looked at a couple and I still like mine more - but I also have a moderate case of not-invented-here syndrome.

Don't we all?

https://github.com/thwarted/shuck

Re: Cronic - A cure for Cron's chronic email problem

#27
post #20

Oh man. I was all excited reading the headline until I realized that you weren't talking about a cure for Crohn's.

One exists. Hookworm aka Helminthic therapy.

Unfortunately the FDA has ruled that this treatment would require approval. The approval process is expensive, and there is no way that anyone can recoup their expenses for doing so. Therefore this treatment will never be approved in the USA.

But I know someone who had severe Crohn's disease who went to Canada to receive a mail order of hookworm. Thanks to that he's been totally off drugs for over a year, and shows no signs of the disease.

Re: Cronic - A cure for Cron's chronic email problem

#28
post #11
post #5

In a dozen or so years of administrating many different Unix machines, I've never had cron email be a problem and I get a few (useful) emails from various cron scripts every day. This interacts badly with many unix commands, which often send status info to standard out. Some commands have a quiet options, but that can turn off all error output too. Maybe it's that I've mostly been administrating BSD machines, and so…

I think it's an OSX-ism. Most OSX devs I've seen treat their command-line utilities like their GUI utilities, with nice looking albeit chatty output. These utilities then get released into the Linux world, where they often work without any modification.

Or it's just younger devs, who like to see something when they run their program.

Re: Cronic - A cure for Cron's chronic email problem

#30
post #24
post #8

I have this problem, I only want to be emailed upon failure. However, the crontab of the account is shared by several different jobs run by different people, and I don't have control over that. Perhaps I could set the email in the crontab line? * * * * * MAILTO=me@example.com blahscript.sh

blahscript.sh | mail -s "Subject" me@example.com

That always sends an email, even if the body is empty.
Post reply on HN