public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] rsync script
@ 2008-03-21  6:52 Kaushal Shriyan
  2008-03-21  7:26 ` Alan McKinnon
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushal Shriyan @ 2008-03-21  6:52 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

Hi

MAILTO=kaushal@example.com
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

Any ideas

Thanks and Regards

Kaushal

[-- Attachment #2: Type: text/html, Size: 384 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  6:52 [gentoo-user] rsync script Kaushal Shriyan
@ 2008-03-21  7:26 ` Alan McKinnon
  2008-03-21  7:33   ` Kaushal Shriyan
  0 siblings, 1 reply; 8+ messages in thread
From: Alan McKinnon @ 2008-03-21  7:26 UTC (permalink / raw
  To: gentoo-user

On Friday 21 March 2008, Kaushal Shriyan wrote:
> Hi
>
> MAILTO=kaushal@example.com
> 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

crontab will only send a mail is there is anyput to stdout. What output 
do you get if you run the rsync manually?

Do you have any packages installed that can actually send the mail?



-- 
Alan McKinnon
alan dot mckinnon at gmail dot com

-- 
gentoo-user@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  7:26 ` Alan McKinnon
@ 2008-03-21  7:33   ` Kaushal Shriyan
  2008-03-21  8:33     ` Collin Starkweather
  2008-03-21 12:22     ` Alan McKinnon
  0 siblings, 2 replies; 8+ messages in thread
From: Kaushal Shriyan @ 2008-03-21  7:33 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 981 bytes --]

On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@gmail.com>
wrote:

> On Friday 21 March 2008, Kaushal Shriyan wrote:
> > Hi
> >
> > MAILTO=kaushal@example.com
> > 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
>
> crontab will only send a mail is there is anyput to stdout. What output
> do you get if you run the rsync manually?
>

Hi Alan

When i run the rysnc command by hand, it runs successfully without any
issues. I can see it on stdout saying building list files........ and then
the rsync process


> Do you have any packages installed that can actually send the mail?
>

 I did not understand this question

Thanks and Regards

Kaushal


>
>
> --
> Alan McKinnon
> alan dot mckinnon at gmail dot com
>
> --
> gentoo-user@lists.gentoo.org mailing list
>
>

[-- Attachment #2: Type: text/html, Size: 1791 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  7:33   ` Kaushal Shriyan
@ 2008-03-21  8:33     ` Collin Starkweather
  2008-03-21  8:59       ` Kaushal Shriyan
  2008-03-21 12:22     ` Alan McKinnon
  1 sibling, 1 reply; 8+ messages in thread
From: Collin Starkweather @ 2008-03-21  8:33 UTC (permalink / raw
  To: gentoo-user

Quoting Kaushal Shriyan <kaushalshriyan@gmail.com>:

> On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@gmail.com>
> wrote:
>
>> On Friday 21 March 2008, Kaushal Shriyan wrote:
>> > Hi
>> >
>> > MAILTO=kaushal@example.com
>> > 0 18 * * * rsync -av /var/lib/mysql kaushal@host77:/var/lib/

Run rsync through a script that tests the exit value, then prints an  
error message if the exit value is not equal to 0 and nothing  
otherwise.  Run the script from cron and it will send you an e-mail if  
there is a problem.

In bash, $? is the exit value of the last command.  This is a bit  
verbose, but you could put the following in rsync-host77.sh:

   #!/bin/bash
   TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
   rsync -av /bogus foo@bar:/bogus/ &>rsync-${TIMESTAMP}.log
   EXITVALUE=$?
   if [[ "${EXITVALUE}" -ne "0" ]]
   then
         echo "Error:  rsync exited with status ${EXITVALUE}"
         echo " "
         echo "Please check the file rsync-${TIMESTAMP}.log for errors."
   fi

To find exit values and their corresponding meanings, search for "EXIT  
VALUES" in

   http://www.linuxmanpages.com/man1/rsync.1.php

Hope this helps,

-Collin

-- 
Collin Starkweather, Ph.D.
http://www.linkedin.com/in/collinstarkweather

--
gentoo-user@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  8:33     ` Collin Starkweather
@ 2008-03-21  8:59       ` Kaushal Shriyan
  2008-03-21  9:38         ` Collin Starkweather
  0 siblings, 1 reply; 8+ messages in thread
From: Kaushal Shriyan @ 2008-03-21  8:59 UTC (permalink / raw
  To: gentoo; +Cc: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 2192 bytes --]

On Fri, Mar 21, 2008 at 2:03 PM, Collin Starkweather <
gentoo@collinstarkweather.com> wrote:

> Quoting Kaushal Shriyan <kaushalshriyan@gmail.com>:
>
> > On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon <alan.mckinnon@gmail.com
> >
> > wrote:
> >
> >> On Friday 21 March 2008, Kaushal Shriyan wrote:
> >> > Hi
> >> >
> >> > MAILTO=kaushal@example.com
> >> > 0 18 * * * rsync -av /var/lib/mysql kaushal@host77:/var/lib/
>
> Run rsync through a script that tests the exit value, then prints an
> error message if the exit value is not equal to 0 and nothing
> otherwise.  Run the script from cron and it will send you an e-mail if
> there is a problem.
>
> In bash, $? is the exit value of the last command.  This is a bit
> verbose, but you could put the following in rsync-host77.sh:
>
>   #!/bin/bash
>   TIMESTAMP=`date +%Y-%m-%d-%H:%M:%S:%N`
>   rsync -av /bogus foo@bar:/bogus/ &>rsync-${TIMESTAMP}.log
>   EXITVALUE=$?
>   if [[ "${EXITVALUE}" -ne "0" ]]
>   then
>         echo "Error:  rsync exited with status ${EXITVALUE}"
>         echo " "
>         echo "Please check the file rsync-${TIMESTAMP}.log for errors."
>   fi
>
> To find exit values and their corresponding meanings, search for "EXIT
> VALUES" in
>
>   http://www.linuxmanpages.com/man1/rsync.1.php
>
> Hope this helps,
>
> -Collin
>
> --
> Collin Starkweather, Ph.D.
> http://www.linkedin.com/in/collinstarkweather
>
> --
> gentoo-user@lists.gentoo.org mailing list
>
>
Hi Collin

Thanks Collin

Correct me if i am wrong please. I want to understand your script

step 1 : put the above code in text file and name it as rsync-host77.sh in
the folder /home/kaushal in the machine where rsync command will execute

step 2 :

cd /home/kaushal
$crontab -e

0 18 * * * rsync -host77.sh

If i want to run the rsync script at 6 pm everyday

Also where will the "rsync-${TIMESTAMP}.log" file will be located, I believe
it will be in /home/kaushal folder. Lets say if i have to put
"rsync-${TIMESTAMP}.log" in /tmp folder

then the above rsync line would look like

rsync -av /bogus foo@bar:/bogus/ &>/tmp/rsync-${TIMESTAMP}.log

is that correct what i understand from your email

Thanks a Lot again

Thanks and Regards

Kaushal

[-- Attachment #2: Type: text/html, Size: 3413 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  8:59       ` Kaushal Shriyan
@ 2008-03-21  9:38         ` Collin Starkweather
  0 siblings, 0 replies; 8+ messages in thread
From: Collin Starkweather @ 2008-03-21  9:38 UTC (permalink / raw
  To: Kaushal Shriyan; +Cc: gentoo-user

Quoting Kaushal Shriyan <kaushalshriyan@gmail.com>:

> Correct me if i am wrong please. I want to understand your script
>
> step 1 : put the above code in text file and name it as rsync-host77.sh in
> the folder /home/kaushal in the machine where rsync command will execute
>
> step 2 :
>
> cd /home/kaushal
> $crontab -e
>
> 0 18 * * * rsync -host77.sh
>
> If i want to run the rsync script at 6 pm everyday
>
> Also where will the "rsync-${TIMESTAMP}.log" file will be located, I believe
> it will be in /home/kaushal folder. Lets say if i have to put
> "rsync-${TIMESTAMP}.log" in /tmp folder
>
> then the above rsync line would look like
>
> rsync -av /bogus foo@bar:/bogus/ &>/tmp/rsync-${TIMESTAMP}.log
>
> is that correct what i understand from your email

You are correct, sir!  You must also, of course, be sure to chmod u+x  
rsync-host77.sh.

Note that if you want an e-mail on either success or failure (your  
original post seemed to indicate this might be the case) bash  
understands "if-then-else-fi".

Cheers,

-Collin

-- 
Collin Starkweather, Ph.D.
http://www.linkedin.com/in/collinstarkweather

--
gentoo-user@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [gentoo-user] rsync script
  2008-03-21  7:33   ` Kaushal Shriyan
  2008-03-21  8:33     ` Collin Starkweather
@ 2008-03-21 12:22     ` Alan McKinnon
  1 sibling, 0 replies; 8+ messages in thread
From: Alan McKinnon @ 2008-03-21 12:22 UTC (permalink / raw
  To: gentoo-user

On Friday 21 March 2008, Kaushal Shriyan wrote:
> On Fri, Mar 21, 2008 at 12:56 PM, Alan McKinnon
> <alan.mckinnon@gmail.com>
>
> wrote:
> > On Friday 21 March 2008, Kaushal Shriyan wrote:
> > > Hi
> > >
> > > MAILTO=kaushal@example.com
> > > 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
> >
> > crontab will only send a mail is there is anyput to stdout. What
> > output do you get if you run the rsync manually?
>
> Hi Alan
>
> When i run the rysnc command by hand, it runs successfully without
> any issues. I can see it on stdout saying building list files........
> and then the rsync process

Most likely cause is that he shell that crontab runs in is NOT the same 
shell as your user account and does not have the same PATH.

Solution: never rely on PATH in a crontab, supply the full PATH 
yourself. Try calling rsync as /usr/bin/rsync as see if that fixes it

> > Do you have any packages installed that can actually send the mail?
>
>  I did not understand this question

crontab does not do SMTP, it does not know how to send mail. You need a 
mailer to be installed - like sendmail or mail


-- 
Alan McKinnon
alan dot mckinnon at gmail dot com

-- 
gentoo-user@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [gentoo-user] rsync script
@ 2008-04-04 10:05 Kaushal Shriyan
  0 siblings, 0 replies; 8+ messages in thread
From: Kaushal Shriyan @ 2008-04-04 10:05 UTC (permalink / raw
  To: gentoo-user

hi

I have the script http://pastebin.com/d4b062d28 and the roots cron
entry are as below

30 2 * * * su sms /usr/local/bin/testrsync_mysql.sh

I am getting the below error

building file list ... rsync: opendir "/var/lib/mysql/wordpress"
failed: Permission denied (13) done mysql/ib_logfile0
mysql/ib_logfile1
Killed by signal 2.
rsync error: unexplained error (code 255) at rsync.c(276) [sender=2.6.9]

Any clue as what is happening

Thanks and Regards

Kaushal
-- 
gentoo-user@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-04-04 10:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21  6:52 [gentoo-user] rsync script Kaushal Shriyan
2008-03-21  7:26 ` Alan McKinnon
2008-03-21  7:33   ` Kaushal Shriyan
2008-03-21  8:33     ` Collin Starkweather
2008-03-21  8:59       ` Kaushal Shriyan
2008-03-21  9:38         ` Collin Starkweather
2008-03-21 12:22     ` Alan McKinnon
  -- strict thread matches above, loose matches on Subject: below --
2008-04-04 10:05 Kaushal Shriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox