echo "Running updates on `date`" > $LOG
That echoes the contents of `date` to the file. You've pointed out that this overwrites the file. If you didn't want to overwrite the file, you would have used >>
Let's expand what I mentioned before.
That expands to:
(We'll use a fake value for $LOG)
cat /var/log/fake.log | grep Wed Jan 26 21:54:32 EST 2005 | mail -s "The log from today" email@example.com
Which won't work. I didn't think through my example clearly enough. You'll need to format the date differently.
Something like this:
would produce this: 012605
. That might be good enough. If you wanted to use the same format used by apps that print to /var/log/messages (on a FC1 system), you would use:
So, the corrected example would be:
You'll notice that the date command is only using the month and day, as that is what you will want to match on. That will show you the log entries that match the month and day.
If you had left the %k:%M:
in there, it would only match on the same hour and minute that the cron script ran on.
Anyway, you see the idea.