Can't Run Excel From A Cron Job Under Windows 7
Kertz, Denis (D)** CTR **
Tue Nov 18 01:36:00 GMT 2014
>>> Try starting cron in terminal session and see if anything comes up.
> Stop (don't kill! Everyone, who use -KILL, must be -KILL'ed) the cron service,
> then start cron in terminal, using `runas /user:... ...'. So it would run
> under proper user, and see if anything come up, when it execute your excel
I was unable to find how to use runas from a terminal. I can simply type runas and it does nothing and I can't find --help or /help. I did find a suggestion to use cygstart so I tried this:
$ cygstart --action=runas '/bin/cygrunsrv --start cron'
Unable to start 'C:\cygwin64\bin\cygrunsrv --start cron': The specified file was not found.
So that didn't work. I did try starting the cron service (cygrunsrv) from a terminal session run as administrator and I tried starting the cron service from the Windows services.msc. Nothing has worked for running an Excel program with my run.excel script.
I created a "null" .xls file that does nothing when run by Excel. I can run my script (run.excel c:/Shared/Bin/null.xls) from a bash prompt and it does nothing (as expected) and terminates but when I run this same script from a cron job Excel starts but never terminates. Running a ps command I see this:
PID PPID PGID WINPID TTY UID STIME COMMAND
5188 1184 5188 4928 ? 1000 19:00:01 /usr/bin/sh
6040 5820 5188 4428 ? 1000 19:00:02 /cygdrive/c/Windows/System32/wscript <-- runs vb script that starts Excel
1808 4464 1808 5704 ? 1000 18:24:25 /usr/sbin/cron
5184 5540 5184 6048 pty1 1000 21:13:03 /usr/bin/bash
3368 5184 3368 5560 pty1 1000 19:00:25 /usr/bin/ps
5820 5188 5188 5820 ? 1000 19:00:02 /usr/bin/sh
4464 1 4464 4464 ? 1000 18:24:25 /usr/bin/cygrunsrv
1184 1808 1808 1184 ? 1000 19:00:01 /usr/sbin/cron
5540 1 5540 5540 ? 1000 21:13:03 /usr/bin/mintty
And I see the Excel.Exe *32 in the process list of Task Manager so I know Excel was started.
Note the above ps command shows the wscript command running which is the command that executes the vb script that runs Excel. Also note that all of these processes including the wscript command show the 1000 UID which is the Upar2 login UID in the /etc/passwd file.
I also look in the services.msc window and the cron service properties shows Login As .\Upar2. I see the same on the WinXP PC where I can run Excel successfully from a cron job.
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin