Sie sind auf Seite 1von 2

Starting/configuring Crontab in Cygwin

By default in Cygwin, crontab will not be running. Cron is a time-based job scheduler in
Unix-like computer operating systems. Cron is driven by a crontab, a configuration file that
specifies shell commands/scripts to run periodically on a given schedule. Below is the format
of Cron.

Prerequisites :
.—————- minute (0 – 59)
| .————- hour (0 – 23)
| | .———- day of month (1 – 31)
| | | .——- month (1 – 12) OR jan,feb,mar,apr …
| | | | .—– day of week (0 – 7) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|||||
* * * * * command to be executed

To install and configure crontab in Cygwin, run below command. This is best method of
configuring crond bcz, its most sensible to windows permissions. Below method make sure
that your crond runs with proper privilege & access to drives.

maddy@optimous-lt
$ cron-config
Cron is already installed as a service under account LocalSystem.
Do you want to remove or reinstall it? (yes/no) yes
OK. The cron service was removed.
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
`
Please enter the password for user ‘maddy’:
Reenter:
Running cron_diagnose …
… 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.

Now, you can start cron daemon using below command

Prerequisites :
maddy@optimous-lt ~
$ net start cron
The requested service has already been started.
`
More help is available by typing NET HELPMSG 2182

Now use following command to create a crontab for the current user..

Prerequisites :
maddy@optimous-lt ~
$ crontab.exe -e
crontab: installing new crontab

Enter the schedule for your command/script. Following is an example of cron entry..

Prerequisites :
*/5 * * * * /home/user/test.pl

Above will run /home/user/test.pl script every 5 mins.

Das könnte Ihnen auch gefallen