Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been actively tweaking my backup script on an Ubuntu 9.04 Jaunty Jackalope Machine - as it is now, the script uses rsync and cron to backup certain folders several times a day. At the end of the script, I use a set of echo commands to generate log files that would indicate, among other things, whether or not the backup had been executed during a particular time. What's the easiest way to make Jaunty automatically email me the logs just shortly (0-15 minutes) after they have been generated? Would I be able to use the SMTP of my gmail account for this purpose?

share|improve this question
add comment

1 Answer

If your cron job produces any output, it will be sent in an email. Normally, the email will be sent to the owner of the crontab file. For instance, the output of root's cron jobs will be sent to root, so you need to make sure that those emails are forwarded to you. As an alternative, you can specify another recipient in the MAILTO variable in the crontab file.

If you do not already have outgoing email set up and working on your Ubuntu box, you will need to do that first. I am not speaking of configuring an email client (formally: mail user agent, MUA), but rather set up an email server (formally: mail transfer agent, MTA) on your system. The server can be configured to be minimal and just forward all email to another email server (e.g., your company or ISP's mail server). sudo aptitude install postfix is a good place to start for this.

share|improve this answer
    
Really? I didn't know that - how to I setup cron to email its output? By the way, I'm using cron as root. I have Evolution setup for outgoing mail, is that what cron would be using? Thanks for this! :) –  techtechmo Sep 10 '09 at 22:46
    
techtechmo, I edited my answer with additional comments on how to set up an email server on your system. –  Vebjorn Ljosa Sep 11 '09 at 11:49
    
techtechmo: cron doesn't know and doesn't care about your Evolution setup. It just calls the local MTA - usually /usr/bin/sendmail (which often is a symlink to postfix or exim4) –  grawity Sep 11 '09 at 11:52
1  
Setting up an email server just to send a file seems a bit overkill. There are other possibilities to email something with outside smtps. See this answer: superuser.com/questions/39634/… –  dertoni Sep 11 '09 at 13:17
    
I actually found that answer yesterday too, I was trying to figure out how I could link it to this post as answer but obviously I was not successful. So I just upvoted on the post. I'm happy to report that because of sendEmail I have finally been able to successfuly integrate a confirmation email and twitter post into my script. Woohoo! :) –  techtechmo Sep 12 '09 at 6:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.