2

I have run installed cygwin with openssh, rysnc and cron. I've run cygserver-config and cron-config

cygcheck -c | grep cron
cron                      4.1-65                       OK

cygrunsrv -Q cron
Service             : cron
Current State       : Running
Controls Accepted   : Stop
Command             : /usr/sbin/cron -n

Windows recognized the service in the correct user context. windows task manager There are no errors in the windows event, cron or cygserver logs. Many resources on the internet insist to use cron-config instead of cygrunsrv -I cron -p /usr/sbin/cron -a -D or cygrunsrv -I cron -p /usr/sbin/cron --args -n. I tried all three. Every thing appears to have installed correctly with cron-config but cron jobs are not running. here is an example of my crontab (yes, it is set to run every minute for debuging purposes!)

crontab -l
* * * * * rsync -avz -e "ssh -i /cygdrive/c/users/path/.ssh/id_rsa" [email protected]:/var/log/path/ /cygdrive/c/destination/path/ --progress

UPDATE: looks like cron is now running and making entries in the windows event log. Unfortunately, now I am running into execution and context errors. error 1 error 2

2
  • Why don't you just use the windows task scheduler? Jul 19, 2017 at 15:32
  • 1
    I would except net start cron gives me "System error 5 has occured. Access is denied"
    – John R
    Jul 19, 2017 at 15:46

3 Answers 3

1

Inside crontab you should always run commands with full path; for rsync it should be

/usr/bin/rsync

1

To further analyze the problem. open your cygwin shell and enter

cronevents
-1

This is not set to run every minute

* * * * * rsync -avz -e "ssh -i /cygdrive/c/users/path/.ssh/id_rsa" [email protected]:/var/log/path/ /cygdrive/c/destination/path/ --progress

This is indeed set to run every minute

*/1 * * * * rsync -avz -e "ssh -i /cygdrive/c/users/path/.ssh/id_rsa" [email protected]:/var/log/path/ /cygdrive/c/destination/path/ --progress
5
  • That's not correct. Those two crontab lines do the same thing. Apr 13, 2021 at 10:51
  • That depends on the implementation * * * * * will do nothing in many crond present in some distros and *NIX systems. */1 will ensure compatibility. Do you believe to know them all?, cause I just need to know one that behaves that way to not be wrong, while you need to know them all to be right. Per instance VMWare ESXi will ignore that line. Which will presumably extend that to all Busybox based systems. You have been too fast shooting man, take it easy. Apr 14, 2021 at 20:23
  • No shooting! Just trying to clarify. No, I don't know them all. I did just check in Cygwin, and man 5 crontab there says "A field may be an asterisk (*), which always stands for ``first-last''." Apr 15, 2021 at 11:37
  • You are contradicting yourself. If those two crontab lines do the same thing and the second is the canonical answer. And it is canonical cause the vast majority of crontabs use that notation, then using my syntax is the first thing to do. Apr 20, 2021 at 10:44
  • The question is about Cygwin. And no, most Unixes don't do it that way. Debian, RedHat, and Cygwin at least don't. Apr 21, 2021 at 10:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .