[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cron Daemon backup message too big

On 31/03/2008, Haines Brown <brownh@hartford-hwp.com> wrote:
Someone kindly communicated to me privately, and I realized that I was
not being sufficiently complete regarding my problem.

In my backup script, I have the line:

  find / -print | egrep -v "^/media|... " 2>&1 | cat -vt

What this command does is to concatenate stdout + errors and redirect
them to a terminal. This works fine when I call the command # backup.

However, when cron calls it, there's no terminal to which to send the
stdout, and so apparently it is redirected by default to a mail

Could I avoid this by terminating the command line instead like this:

  2>&1 /home/brownh/backup.log | cat -vt


  Almost right, though you need a redirect to the file too like so: `2>&1 1>/home/brownh/backup.log`. Note the '1' for stdout is optional, if it is left off it is assumed. This will send absolutely nothing through to `cat`.

  If passing through `cat` is necessary for formatting your output then use something like this:
`2>&1 | cat -vt > /home/brownh/backup.log` This passes both stderr and stdout through cat and then into the log file.

`2>&1` means literally send stderr to where stdout is going now.
 The order matters here, if you use `2>&1 >/home/brownh/backup.log` then stderr will be coming out to where stdout defaulted to (in this case to cron's mail) and stdout will be going to the file. This could also be desireable.

  Also, with `cat -vt` the arg '-t' == '-vT' making your argument string play out to '-vvT'. At a guess you are either after just '-t' or trying to explicitly give '-vT'.


Here I clobber the contents of backup.log, which is what I want. Is the
syntax right? Will it avoid sending stdout to a mail message?

My guess is that when I upgraded to etch, cron stdout was redirected by
default to a mail message. That's OK, except in this case it causes
exim4 to complain about the size of the message and terminate the find


       Haines Brown, KB1GRM


Reply to: