Cronic - A cure for Cron's chronic email problem
habilis.net
habilis.net
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 most of the tools follow old Unix guidelines like not printing anything unless it's necessary, echoing errors to stderr, using proper exit statuses, etc. (http://fmg-www.cs.ucla.edu/geoff/interfaces.html) I think it's a GNUism/Linuxism that commands are overly chatty, writing junk all over stdout (like author/license information - do we need to see this every single time?), and using ANSI colors by default.
I'm sure there are exceptions somewhere. But in something you'd throw into a cron job? Frankly, that seems like a very weird snipe.
I see less of the license stuff these days but no doubt there's a few around.
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.
They did sometimes put the license everytime, a long time ago, but I don't see that anymore unless you ask the version or help.
echo 1 + 2 | bc
That doesn't produce anything except "3", even with GNU bc.
Cron isn't broken. It's chatty programs that are broken.
(Disclaimer: I wrote isutf8, which is included in moreutils.)
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 ...).
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.
$ command >file.txt 2>&1
first redirects fd=1 to file.txt and then has fd=2 go the same place. Where: $ command 2>&1 >file.txt
first has fd=2 go the original place stdout was and then redirect fd=1 only to file.txt. Usually not what you want. If you really wanted file.txt to get only the stdout while simultaneously sending what used to be stderr to stdout I think you'd have to use another file descriptor like: $ command 3>&1 >file.txt 2>&3
That is, save the original stdout as fd=3, redirect stdout, then make stderr go the same place fd=3 is going.And that's exactly what usually happens; we replace fd 1 with one open to /dev/null, and then when we say 2>&1, that means to replace fd 2 (stderr) with whatever's at fd 1 (now /dev/null). When you write "command 2>&1 >/dev/null" that means something else, it means "send fd 2's output to what's currently at fd 1 (stdout)", and then "send what's currently at fd 1 to /dev/null". In other words, the source of a redirection is "by reference", but the destination of a redirection is "by value". If that makes any sense...
[1] http://wiki.bash-hackers.org/syntax/redirection#multiple_red...
$ 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?) perl -E 'say q{STDOUT!}; say {*STDERR} q{STDERR!}'
(q{...} quoting to avoid ugliness of quotes inside quotes.)* * * * * MAILTO=me@example.com blahscript.sh
blahscript.sh | mail -s "Subject" me@example.com MAILTO=user1@example.com
* */10 * * * script1
5 * * * * script2
MAILTO=user2@example.com
* * * * * script3
Any output from script1 and 2 will be sent to user1 and any from script3 to user2.* * * * * blahscript.sh
and it'd do what cronic does without any extra. I know i know the "one tool one job", but i believe this job is really cron's job (word play unintended)
cron sends a mail if: a) there's output (stdout or stderr) or b) the command exit code isn't 0.
So I really don't understand the post when it says "Now when your cron job fails, you will never know about it.".
Well, if you script fails and still returns 0, your script is broken. If you script outputs stuff when it's not supposed to, it can't run from cron.
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.
(that alone is worth the article. the "real" content is just misunderstanding of unix i'm afraid)