cron works only when screen is locked - error in eventviewer

Peder Sverdrup psverdrup@yahoo.com
Sat Apr 2 16:16:00 GMT 2016


Hi, 
I would like to run linux .sh and Windows bat-scripts and exe-files from crontab. I guess this should be possible with Cygwin? 
My machine is Win 10 Pro 64-bit, old hardware with bios. 

So I install Cygwin64, the base install + the packages: openssh, rsync and cron. When I install cron, I see that also cygrunsrv is installed, even if I did not choose this in the cygwin setup program. 

Without any more work I can ssh to my remote Debian server. I can do this from the cygwin shell, and also from Windows cmd. 

In cygwin shell I can also run my rsync script myrs.sh to backup files in the directory c:\00buptmp\. to the Debian. 

Now I want to run myrs.sh with crontab. I run cron-config: 

-- 
Do you want to install the cron daemon as a service? (yes/no) yes 
Enter the value of CYGWIN for the daemon: [ ] 
Do you want the cron daemon to run as yourself? (yes/no) yes 
Do you want to start the cron daemon as a service now? (yes/no) yes 
-- 

Is the value for CYGWIN correct? I have no idea what it should be. What about the rest? 

However, cron does not work correctly. Sometimes it works, sometimes not, and it is difficult to pinpoint exactly what makes it work or not. To me it seems like it has some connection to the screen on my machine being locked or not. Locked in the sense I need to enter my password to get back into Windows. When it is locked, cron runs the script myrs.sh correctly. Cron also runs a Windows exe file: 

53      14      *       *       *       /home/april/01bupsource/myrs.sh 
46      14      *       *       *       /cygdrive/c/05prog/putty/putty.exe 

In the Event viewer, Application-log, I get the info-message: 

-- 
The description for Event ID 0 from source /usr/sbin/cron cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. 

If the event originated on another computer, the display information had to be saved with the event. 

The following information was included with the event: 

/usr/sbin/cron: PID 8956: (april) CMD (c:\05prog\putty\putty.exe) 
-- 

I then remove cron as a Windows service, by running: 

cygrunsrv --stop cron 
cygrunsrv --remove cron 

And now, from the cygwin shell, cron seems to run correctly. It also runs when my sreen is not locked. 

See attached file cronbug.txt, recorded before I removed cron as a win service. 

So my question is - how do I get this to work? And how should it work? 
I need to run cron-config again - what is the recommended parameters? 
On the internett I read several places that instead of running cron-config one can do 
cygrunsrv --install cron --path /usr/sbin/cron --args -n 
Is that correct? With what credentials will cron and its jobs run with? 
I had a look in the cron-config script and the install-line is more complex. 
What is the point of cygrunsrv - is it that cron wil always run even when cygwin shell is not open? It just needs Windows  to run. And the service can be started, stopped etc from Windows. 
Can I run Windows bat-scripts from cron?
I also want to be able to send email from cron and myrs.sh script. Should this be taken into consideration now or later? exim? 

I guess this was a lot.. any help is much appreciated. I am new to cygwin. 

Kind regards, Peder Sverdrup 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cronbug.txt
URL: <http://cygwin.com/pipermail/cygwin/attachments/20160402/52fe9abe/attachment.txt>
-------------- next part --------------
--
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


More information about the Cygwin mailing list