C3rd
Running Cronjob or Cron or Crontab in Cygwin
Posted: 28 Feb 2013, 0:37am - ThursdayYou need to install few packages. So we need the setup.exe file of the cygwin to do the package installations. Cast the following commands to install cron:
setup.exe -q -P cygrunsrv setup.exe -q -P exim setup.exe -q -P ssmtp setup.exe -q -P cronexim and ssmtp -- You can install either of the package. Purpose of this is if you want to send an email after the task or job has been executed. So after installation... go to Cygwin terminal and cast the following commands and test it...
camilo@Camilo-PC ~ $ cygrunsrv -I cron -p /usr/sbin/cron -a -D camilo@Camilo-PC ~ $ net start cron The cron service is starting. .... camilo@Camilo-PC ~ $ crontab -l no crontab for camiloThat's it... You have running crontab in your Cygwin. You may now import or create task schedules. Hope this will help for those trying to do the same. [After an hour] ==---- After browsing why my cron is not working, it does not execute my task. So I researched and found the answer...
To be honest, making this work is tenuous at best. MS doesn't want things to work this way anymore because it's viewed as a security hole (arguably a valid point). If you're running XP, then you have a better chance but, as you've noticed, it's not guaranteed either. And it will most certainly stop working if you move to a later O/S version. I know. Not what you wanted to hear and some additional research and perseverance on your part may unearth a solution that works for you. But there's no magic bullet here, sorry. -- LarryReference: http://cygwin.com/ml/cygwin/2012-08/msg00223.html Well, I guess our journey ends here on running cron in windows via Cygwin... :)
AFTER YEARS PASSED... Zabby (tallalex[at]gmail.com) message me about this blog and would like to update this that the crontab in cygwin is now possible. I haven't tried it but I read few articles that they made it work. Commonly I read are (from stackoverflow.com): You have two options:
- Install cron as a windows service, using cygrunsrv:
cygrunsrv -I cron -p /usr/sbin/cron -a -D
net start cron
- The 'non .exe' files are probably bash scripts, so you can run them via the windows scheduler by invoking bash to run the script, e.g.:
C:\cygwin\bin\bash.exe -l -c "./full-path/to/script.sh"
cygrunsrv --install cron --path /usr/sbin/cron --args -nIf you executed the last command, delete the old service first by typing the command below in MS-DOS CLI:
sc delete cronI think that's it for the update for today.. :) In case you need to run ssh server or sshd, just cast the command below and follow the instructions.
ssh-host-configmake sure you allow it to your firewall.