Search This Blog

Tuesday, July 24, 2012

Cron setup for cygwin

########################################
# Cron configuration in Windows
########################################

$ cron-config 
Do you want to install the cron daemon as a service? (yes/no) yes
Enter the value of CYGWIN for the daemon: [ ] ntsec

You must decide under what account the cron daemon will run.

If you are the only user on this machine, the daemon can run as yourself.
   This gives access to all network drives but only allows you as user.
To run multiple users, cron must change user context without knowing
  the passwords. There are three methods to do that, as explained in
  http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1
If all the cron users have executed "passwd -R" (see man passwd),
  which provides access to network drives, or if you are using the
  cyglsa package, then cron should run under the local system account.
Otherwise you need to have or to create a privileged account.
  This script will help you do so.
Do you want the cron daemon to run as yourself? (yes/no) yes

* If cron run multiple users, it needs to change user context; therefore, the user passwords need to be kept in a place, which the service can access.

See http://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-nopasswd1 for details. 

* passwd -R: enter password to store it in the registry for later usage by services to be able to switch to this user context with network credentials.


* If the cron daemon needs to run under the local system account, say no for the question above.

Please enter the password for user 'user': 
Reenter: 
Running cron_diagnose ...
WARNING: You do not currently have a crontab file.

... no problem found.


Do you want to start the cron daemon as a service now? (yes/no) yes

OK. The cron daemon is now running.

In case of problem, examine the log file for cron,

/var/log/cron.log, and the Windows event log (using /usr/bin/cronevents)
for information about the problem cron is having.

Examine also any cron.log file in the HOME directory

(or the file specified in MAILTO) and cron related files in /tmp.

If you cannot fix the problem, then report it to cygwin@cygwin.com.

Please run the script /usr/bin/cronbug and ATTACH its output
(the file cronbug.txt) to your e-mail.

WARNING: PATH may be set differently under cron than in interactive shells.

         Names such as "find" and "date" may refer to Windows programs.


$ net start cron
The requested service has already been started.

More help is available by typing NET HELPMSG 2182.


$ crontab -e


Following script runs script.sh every noon.


0 12 * * * /home/user/program/script.sh


cron.log can be found out in ~.


Remove cron service


net stop cron

sc delete cron

########################################
# Cron debugging in Windows
########################################

1. cat /Var/log/cron.log
2. cronevents.exe

No comments:

Post a Comment

Blog Archive