Installing Cron on Cygwin

To set up cron on Cygwin, first install the cron package with the Cygwin installer. Then install cron as a service.


cygrunsrv -I cron -p /usr/sbin/cron -a D

After the service is installed, it can be started.


net start cron

By default, crontab is set up to use vi as its editor. I prefer nano, so I change the EDITOR environment variable to let crontab aware of my preference. I edit $HOME/.bash_profile and add the following lines.


EDITOR=nano
export EDITOR

I then re-read the BASH profile.


source $HOME/.bash_profile

Finally, the crontab file can be edited in the usual way.


crontab -e

cygrunsrv itself has to be

cygrunsrv itself has to be installed as well. It can be found in the "Admin" category right under cron.

Note the correct sintax for

Note the correct sintax for passing service parameters is

cygrunsrv -I cron -p /usr/sbin/cron -a -D

Nice article, very

Nice article, very helpful.

You should update it though to reflect rleblic's correction though.

Is it possible to make cron

Is it possible to make cron to read .bash_profile file? And if yes: does it read the /.bash_profile or the home/Administrator/.bash_profile (as it's installed on cyg_server account)?

Thanks in advance
Ela

@Ella You could always

@Ella

You could always manually `source' your .bash_profile in the scripts that you call through cron.

Very good post, thanks a

Very good post, thanks a lot.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options