Rsync works fine at command line but not through cron - Tools

This is a discussion on Rsync works fine at command line but not through cron - Tools ; Hi, I've setup rsync to provide an off-site backup mirror through an SSH session. I initiate rsync through a short bash script. I'd got everything set up and it seemed to be working fine (I've done several runs from the ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Rsync works fine at command line but not through cron

  1. Rsync works fine at command line but not through cron

    Hi,

    I've setup rsync to provide an off-site backup mirror through an SSH
    session. I initiate rsync through a short bash script. I'd got
    everything set up and it seemed to be working fine (I've done several
    runs from the command line over the last two days to make sure it was
    all working as it should).

    However, now I've come to automate it with a cron job it fails every
    time. I've Goggled and found others have had problems with cron jobs but
    none seem to have the error message I'm getting and I'm completely stuck
    as to what to try next so any help would be very greatly appreciated.

    The local system is SuSE 9.2, the remote is FreeBSD (running in daemon
    mode). The (local) cron job is setup against the same user as I use at
    command line (not root). The cron job also executes that same bash
    script as I execute manually from the command line.

    The error I get is "rsync error: errors with program diagnostics (code
    13) at log.c(222)" each time.

    The script is issuing the following command:

    rsync --progress --archive --compress --stats --delete -e ssh $LOCALDIR
    $USERNAME@$HOSTNAME:$REMOTEDIR

    and all variables are correctly set within the bash script. If I run
    rsync with -vvv the line immediately before the error is:

    recv_generator(Draft Designs/Lots of hearts (Mulberry)/lots of hearts -
    ty.cdr,1533)

    although, as I say, the actual file it fails on varies each time.

    If I execute the same bash script from the command line (as the same
    user) it completes and synchronises the files.

    Anyone any idea what's wrong.

    Thanks, David

  2. Re: Rsync works fine at command line but not through cron

    David wrote:
    > Hi,
    >
    > I've setup rsync to provide an off-site backup mirror through an SSH
    > session. I initiate rsync through a short bash script. I'd got
    > everything set up and it seemed to be working fine (I've done several
    > runs from the command line over the last two days to make sure it was
    > all working as it should).
    >
    > However, now I've come to automate it with a cron job it fails every
    > time. I've Goggled and found others have had problems with cron jobs but
    > none seem to have the error message I'm getting and I'm completely stuck
    > as to what to try next so any help would be very greatly appreciated.
    >
    > The local system is SuSE 9.2, the remote is FreeBSD (running in daemon
    > mode). The (local) cron job is setup against the same user as I use at
    > command line (not root). The cron job also executes that same bash
    > script as I execute manually from the command line.
    >
    > The error I get is "rsync error: errors with program diagnostics (code
    > 13) at log.c(222)" each time.
    >
    > The script is issuing the following command:
    >
    > rsync --progress --archive --compress --stats --delete -e ssh $LOCALDIR
    > $USERNAME@$HOSTNAME:$REMOTEDIR
    >
    > and all variables are correctly set within the bash script. If I run
    > rsync with -vvv the line immediately before the error is:
    >
    > recv_generator(Draft Designs/Lots of hearts (Mulberry)/lots of hearts -
    > ty.cdr,1533)
    >
    > although, as I say, the actual file it fails on varies each time.
    >
    > If I execute the same bash script from the command line (as the same
    > user) it completes and synchronises the files.
    >
    > Anyone any idea what's wrong.
    >
    > Thanks, David

    OK, an upgrade (I was running rsync 2.6.3) seems to have mainly cured
    this (although I've no idea what the problem was, simply upgrading rsync
    without changing either my bash script or the cron job, let it run
    through to completion).

    However, there is still another minor problem. When I run the cron job
    it usually reports an I/O error (seems to be immediately after it has
    worked out how many files it is considering) and so negates the --delete
    option. This doesn't happen from the command line. I appreciate there is
    an option to --delete despite I/O errors but why should I get I/O errors
    through cron and not from an interactive command prompt?

    Thanks, David

+ Reply to Thread