cron job email results...
I have a cron job /etc/cron.daily/update and I would like to be email the results. The problem is there are multiple commands within the job. For example:
Code:
#!/bin/sh Code:
Running updates on Wed Jan 26 13:05:46 CST 2005 Thank you! TheGNUbie |
At the end of the cron job, do something like this:
|
Where you have `date`, use anything you want to match on.
|
yeah but
wont that only return 1 line? (ie.. the date line)
I want to see everything from todays date down. |
actually I just notice that its not appending to the log like I had hoped.. so I guess I can just email the whole log to myself.
|
Quote:
Okay. Let's expand what I mentioned before. Quote:
(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" your.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: Quote:
Quote:
So, the corrected example would be: Quote:
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. |
Re: yeah but
Quote:
*doh* I just realized what you were asking. I was somewhere off in left field. In that case, have your script start off like this: Code:
#!/bin/sh Try that out and let me know how it works. ;) |
Instead of redirecting stdout to $LOG, you could tee it to $LOG. So, for example, the line
Code:
urpmi.update updates >> $LOG 2>&1 Code:
urpmi.update updates 2>&1 | tee -a $LOG |
All times are GMT -5. The time now is 03:25 AM. |