View Full Version : Running cron as a windows service for rsync
MachineDog
8 Jun 2009, 6:01am
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. :/
set up a simple cron task to make sure it's working.
( touch /cygdrive/g/test )
MachineDog
8 Jun 2009, 6:32am
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.
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?
MachineDog
8 Jun 2009, 7:21am
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... :\
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
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
MachineDog
8 Jun 2009, 6:34pm
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?
/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
MachineDog
9 Jun 2009, 1:32am
/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. :)
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.