Kaushal Shriyan wrote:
Hi MAILTO=kaushal@xxxxxxxxxxx 0 18 * * * rsync -av /var/lib/mysql kaushal@host77:/var/lib/ If i put this two lines in crontab it will run correctly,My requirement was to create a script, this script should indicate success or failures and the reason for failure
Rsync should already be telling you that in the email that cron sends but you probably aren't bothering to read it because the -v option makes it too verbose. If you you can't get rsync to say exactly what you want with some variation (or omission) of the -v and -q options you could replace the success output with an invocation like: 0 18 * * * rsync -a /var/lib/mysql kaushal@host77:/var/lib/ >dev/null && echo Rsync succeeded
Cron only sends mail if the command generates anything on stdout or stderr. The >dev/null will discard normal output but keep any error messages from rsync (which would go to stderr instead of stdout). If the run succeds with no error, the command to the right of the && will run so you still get an email.
Somehow the way you stated the 'requirement' for a script makes this sound like a homework assignment from someone who expects it to look like cobol, though...
-- Les Mikesell lesmikesell@xxxxxxxxx