Running cron as a windows service for rsync

edited June 2009 in Science & Tech
I have been attempting to setup cron as a service using cygwin/cygrunsrv so I can get rsync to run daily, and have been having trouble.

The service is running under my user as it would not run as a local system account. (I can't imagine why that might screw anything up but maybe it does.)
I attempted having rsync output to a .txt file as a log and it doesn't output anything. I've manually run rsync just fine in the past so I think the problem is with cron.

Here is my crontab file:
0 0 * * * rsync -ur /cygdrive/d/documents /cygdrive/g
0 0 * * * rsync -ur /cygdrive/d/photoalbum /cygdrive/g

I'm not sure if that crontab is correct but I'm pretty sure it is. The rsync part of it is.

Any ideas, new to using cron. :/

Comments

  • shwaipshwaip bluffin' with my muffin Icrontian
    edited June 2009
    set up a simple cron task to make sure it's working.

    ( touch /cygdrive/g/test )
  • edited June 2009
    shwaip wrote:
    set up a simple cron task to make sure it's working.

    ( touch /cygdrive/g/test )

    Okay I will try something.

    edit: No file is created.
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited June 2009
    So I've never used cron on cygwin, but:

    1) did you edit your crontab file using crontab -e ?
    2) are you sure you have permission to write to that location? You might want to try touching a file in your cygwin homedir.
    3) try making rsync write a log file to your homedire also.
    4) are you sure cron is running as a service?
  • edited June 2009
    shwaip wrote:
    So I've never used cron on cygwin, but:

    1) did you edit your crontab file using crontab -e ?
    2) are you sure you have permission to write to that location? You might want to try touching a file in your cygwin homedir.
    3) try making rsync write a log file to your homedire also.
    4) are you sure cron is running as a service?

    1) Yes.
    2) I made sure of that.
    3) I will try that.
    4) Yep, I checked a couple of different websites and they all had the same instructions.. I think there must be something simple wrong... :\
  • kryystkryyst Ontario, Canada
    edited June 2009
    If you've got cygwin as part of the path you can just execute rsync from the command prompt in dos without having to go through cygwin. For example I use rsync to do backups and just call it up using windows scheduler through a batch file that looks like this
    @echo off
    echo off
    
    :backup
    echo off  
    set PATH=%path%;m:\rsync 
    set CYGWIN=binmode tty 
    set HOME=m:\rsync 
    
    echo Desktop Backup 
    START /LOW /B m:\rsync\rsync.exe -q -rlt -z --delete "/cygdrive/c/documents and settings/%username%/Desktop" "/cygdrive/u/%computername%/"
    
    echo Documents Backup 
    START /LOW /B m:\rsync\rsync.exe -q -rlt -z --delete "/cygdrive/c/documents and settings/%username%/My Documents" "/cygdrive/u/%computername%/"
    

    So this just backs up a users desktop and documents to their U:drive on the network server. It's a bat file that is run through windows scheduler. The files all exist on the network nothing is installed on a users computer.

    So the directory just needs. The specific files for rysnc and cygwin and the .bat file of course...

    backup.bat
    cygwin1.dll
    rsync.exe
  • kryystkryyst Ontario, Canada
    edited June 2009
    Lifehacker just did a write up on a simple way to use and schedule rysnc backups for windows.

    http://lifehacker.com/5281024/nasbackup-makes-incremental-backups-easy
  • edited June 2009
    kryyst wrote:
    If you've got cygwin as part of the path you can just execute rsync from the command prompt in dos without having to go through cygwin. For example I use rsync to do backups and just call it up using windows scheduler through a batch file that looks like this
    @echo off
    echo off
    
    :backup
    echo off  
    set PATH=%path%;m:\rsync 
    set CYGWIN=binmode tty 
    set HOME=m:\rsync 
    
    echo Desktop Backup 
    START /LOW /B m:\rsync\rsync.exe -q -rlt -z --delete "/cygdrive/c/documents and settings/%username%/Desktop" "/cygdrive/u/%computername%/"
    
    echo Documents Backup 
    START /LOW /B m:\rsync\rsync.exe -q -rlt -z --delete "/cygdrive/c/documents and settings/%username%/My Documents" "/cygdrive/u/%computername%/"
    
    So this just backs up a users desktop and documents to their U:drive on the network server. It's a bat file that is run through windows scheduler. The files all exist on the network nothing is installed on a users computer.

    So the directory just needs. The specific files for rysnc and cygwin and the .bat file of course...

    backup.bat
    cygwin1.dll
    rsync.exe

    Thanks! I'll try this I imagine it should work.
    What's the /B for?
  • kryystkryyst Ontario, Canada
    edited June 2009
    /B switch for the start command

    Start application without creating a new window. The
    application has ^C handling ignored. Unless the application
    enables ^C processing, ^Break is the only way to interrupt
    the application.

    So it's about making things run in the background
  • edited June 2009
    kryyst wrote:
    /B switch for the start command

    Start application without creating a new window. The
    application has ^C handling ignored. Unless the application
    enables ^C processing, ^Break is the only way to interrupt
    the application.

    So it's about making things run in the background

    Gotcha, thanks. :)
Sign In or Register to comment.