RE: Cron Problem
>> Have you redirected stdout to stdin ...
Graham Smith wrote:
> ... (I think you mean stderr to stdout).
Yes. My mind jelly turning into seems to be lately... :-)
> Although I've been using Linux for a while I haven't learnt much
> about the shell.
Get this book:
> ... abandons it's output and relies on cron to mail it to me.
I find it's easier/ faster to debug if I dump everything into a log file. YMMV.
> just the amount of time it takes to run.
I had similar questions, and that's why I put the `date` invocation into the
scripts run by cron:
echo ===== `date` ===== end: '$Id: cron-backup,v 1.9 2004/12/08 0
5:59:11 dpchrist Exp $' ===== 2>&1 | tee -a $LOG
Without the Bash book and knowledge of CVS, the above line may look like
gibberish. I'll try to translate:
echo the echo(1) command -- print command-line arguments on
===== something that's easy to see in a crowded log file.
`date` invoke the date(1) command and substitute the output in this place
end: a string that matches a similar "begin:" line earlier in the script
'$Id: cron-backup ...$'
I keep this script under version control using cvs(1). $Id$
is a CVS keyword that is expanded by cvs whenever I check out
the file. It is enclosed in single quotes so that the bash
shell doesn't try to execute any of the stuff in there.
2>&1 redirect stderr to stdout
| send the stdout of the previous command to the stdin of the
next (shell command pipe)
tee the tee(1) command -- copies stdin to stdout and stdin to a
-a append option for tee(1) command
$LOG expanded by the Bash shell to be the value of the shell
variable LOG; e.g. the name of the log file
BTW here is the book for CVS: