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" foo.bar@ssh-target.com:/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

John R
  • 383
  • 4
  • 13

3 Answers3

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
MadMike
  • 163
  • 7
-1

This is not set to run every minute

* * * * * rsync -avz -e "ssh -i /cygdrive/c/users/path/.ssh/id_rsa" foo.bar@ssh-target.com:/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" foo.bar@ssh-target.com:/var/log/path/ /cygdrive/c/destination/path/ --progress
  • That's not correct. Those two crontab lines do the same thing. – Andrew Schulman Apr 13 '21 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. – Tienda Angela Haring Apr 14 '21 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''." – Andrew Schulman Apr 15 '21 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. – Tienda Angela Haring Apr 20 '21 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. – Andrew Schulman Apr 21 '21 at 10:44