This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cron on Windows 7 as a Service Does Not Execute Jobs


At 06:43 PM 11/20/2009, randomerror wrote:
All,

I can't seem to get cron to execute jobs under Windows 7 (Ultimate.) Here are the things I've done...

----------------------------------------
Installed cygwin for all users, and fixed some permission problems.
Configured sshd and it works fine.
Configured exim (without running it as a service) and it works fine (delivers mail through a smart host).


----------------------------------------
Configured cron through cron-config running under cyg_server (that was created by sshd,) and it runs but does not execute jobs.
Cronevents shows that the job commands are running, but in reality they are not:


2009/11/20 17:49:02 [cyg_server] /usr/sbin/cron: PID 4080: (user) CMD (echo test)
2009/11/20 17:50:01 [cyg_server] /usr/sbin/cron: PID 4028: (user) CMD (echo test)
2009/11/20 17:53:01 [cyg_server] /usr/sbin/cron: PID 3384: (user) CMD (sleep 30)
2009/11/20 17:54:01 [cyg_server] /usr/sbin/cron: PID 1404: (user) CMD (sleep 30)
2009/11/20 18:24:01 [cyg_server] /usr/sbin/cron: PID 3928: (user) CMD (echo test > /tmp/abcd)
2009/11/20 18:25:01 [cyg_server] /usr/sbin/cron: PID 2004: (user) CMD (echo test > /tmp/abcd)


The sleep job was to test whether I can see the job run with ps; I could not.

----------------------------------------
So I ran cron from the command line (starting MinTTY as an Administrator) as follows:


/usr/sbin/cron -n -x ext,sch,proc,pars,load,misc,bit

This worked: jobs were being executed and output was e-mailed via exim.

----------------------------------------
Next, I tried to run cron as SYSTEM but that of course failed, with cron starting and immediately stopping.
Lastly, I used strace to attach to the running cron service, which works up until the point that the job execution would begin:


$ ps -ef
     UID     PID    PPID TTY     STIME COMMAND
cyg_serv    3752       1   ?  13:53:57 /usr/bin/cygrunsrv
cyg_serv    2172    3752   ?  13:53:57 /usr/sbin/sshd
cyg_serv    1020       1   ?  17:47:17 /usr/bin/cygrunsrv
cyg_serv    1144    1020   ?  17:47:17 /usr/sbin/cron
   janos    3240       1   ?  18:28:21 /usr/bin/mintty
   janos    1168    3240   0  18:28:22 /usr/bin/bash
   janos    2192    1168   0  18:29:58 /usr/bin/ps

user@host ~
$ strace -f -p 1144
**********************************************
Program name: C:\cygwin\usr\sbin\cron.exe (pid 1144, ppid 1020)
App version: 1005.24, api: 0.156
DLL version: 1005.25, api: 0.156
DLL build: 2008-06-12 19:34
OS version: Windows NT-6.1
Heap size: 402653184
Date/Time: 2009-11-20 18:35:19
**********************************************
.
.
.
183 42989963 [main] cron 3012 build_env: envp 0x61169EB0, envc 28
46 42990009 [main] cron 3012 child_info::child_info: subproc_ready 0x198
8151 42998160 [main] cron 3012 spawn_guts: 3012 = spawn_guts (/bin/sh, C:\cygwin\bin\sh.exe -c "/bin/echo test")
98 42998258 [main] cron 3012! spawn_guts: new process name C:\cygwin\bin\sh.exe
135 42998393 [main] cron 3012! _pinfo::dup_proc_pipe: duped wr_proc_pipe 0x4 for pid 3012(2056)
Windows process 4080 attached
Windows process 3004 attached
Windows process 3012 attached
strace: couldn't attach to subprocess 2056 for debugging, windows error 5


This crashes cron, so it needs to be restarted.

----------------------------------------
Does anybody have any pointers on what else to check or how else to diagnose why the jobs are not running?


Regards,

John

You have done everything right, AFAICS, and a pretty good debugging job. I see "user" in the log, is that an actual user name ?

Except for that, as far as cron is concerned, everything looks OK.
Presumably you have seen a successful setuid in the strace.
Cron prints the log line and execs sh, without checking if it succeeds, but there
is nothing it can do about that. It's a cygwin issue.
Presumably you are using 1.7
Unfortunately I don't have Windows 7 to reproduce the problem.


Not sure what to suggest. Perhaps running "strace  cron" as a service
would give you more info. That will fill /var/log/cron.log pretty fast :)


Pierre (cron maintainer)








-- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]