LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-26-2009, 02:15 AM   #1
mdg
Member
 
Registered: Sep 2003
Distribution: Slackware
Posts: 626

Rep: Reputation: 37
cron job sends email


I have rsnapshot running a system of backups and I want to be notified by email at the end of the daily backup.

This is the command running the cron job:
Code:
50 2 * * *      /etc/rsnapshot_daily  2>&1 | sh /home/marc/rsnapshot_log.sh
and this is the rsnaphot_log script to send me the email:
Code:
#!/bin/bash
  tail -14 /var/log/rsnapshot 2>&1 | mail -v -s "rsnapshot_daily"  my@email.address
The backup works fine and I do get the email, but the mail is sent before the backup finishes, which means the content of the email is relevant to a previous backup.
How can I get the rsnapshot_log script to be executed only after the backup has successfully run?
 
Old 12-26-2009, 03:50 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
First try to change the pipe with "&&" in the crontab entry. Second, be sure the commands inside /etc/rsnapshot_daily are not executed in background, causing the end of the script execution before the backup has been completely performed.
 
Old 12-26-2009, 04:40 AM   #3
mdg
Member
 
Registered: Sep 2003
Distribution: Slackware
Posts: 626

Original Poster
Rep: Reputation: 37
Thanks Colucix, that did the trick. It's running as it should, I'm happy.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank email on Cron job Taleya Linux - Newbie 3 12-19-2007 08:52 PM
cron job email results... ryedunn Linux - General 7 01-26-2005 11:27 PM
cron job that email a text file paynsr Linux - Newbie 1 03-29-2004 02:36 PM
Cron job , send email mikeshn Linux - General 1 09-21-2003 10:02 AM
Send Email + Txt Attachment Using Cron Job beringer Linux - Newbie 3 01-31-2003 11:23 AM


All times are GMT -5. The time now is 02:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration