Email Myself Output of Cronjob?

Carlosinfl

Loves the juice
Joined
Sep 25, 2002
Messages
6,633
I have the following Cron job scheduled on my Postfix mail server:

Code:
00 18 * * * /usr/bin/clamscan -r --remove /home/

This is just running a scan on my entire /home/ directory and removing any infected files it finds. My question is since this is being ran at 6pm via Cron, how can I get the results of this job emailed to me via text? Does anyone recommend a command I can add to the end which will dump the results into a file or email and send it to a specific email address? This server is my company Postfix MTA for everyone.

Thanks for any help / suggestions.
 
You can pipe the output to the 'mail' command. Install 'mailx' and you'll have it if you don't already.
 
cron should send any output of the jobs to the user who owns the job. Set up an alias to forward to your real e-mail (set one up for root too while you're at it). You should probably do this anyway.
 
cron should send any output of the jobs to the user who owns the job. Set up an alias to forward to your real e-mail (set one up for root too while you're at it). You should probably do this anyway.

keenan's method is quick and easy, and should work for you ... however if you need to connect to an external mail server, do authentication, etc, I've found smtp-client.pl to be very helpful.
 
cron should send any output of the jobs to the user who owns the job. Set up an alias to forward to your real e-mail (set one up for root too while you're at it). You should probably do this anyway.

we have a winner
 
Back
Top