This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cron in cygwin

I'd love to hear the "correct" answer for this.  This is the solution I've
come up with, and but it is way too complicated...

1. Install the SYSV init package.
2. Configure the "init" package:
3. Replace the /etc/inittab with the one I've attached.
4. Save the attached script as /usr/sbin/ .
5. Create the directory /var/lock/subsys:
      mkdir -p /var/lock/subsys
5. Uninstall the init service:
      cygrunsrv -R init
6. Install the script as the init service:
      cygrunsrv -I init -p /usr/sbin/  -d "CYGWIN init" -s INT -o
7. Stop the new service:
      cygrunsrv --stop init
8. Clean the /var/log directory:
      rm /var/log/*
    (Some daemons refuse to start otherwise.)
9. Save the attached cron script as /etc/rc.d/init.d/cron
10. Create the following symbolic links:
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc0.d/K25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc1.d/K25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc2.d/S25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc3.d/S25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc4.d/S25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc4.d/S25cron
      ln -s /etc/rc.d/init.d/cron /etc/rc.d/rc6.d/S25cron
11. Restart the init service:
      cygrunsrv --start init


If you have problems, try removing files that are automatically created, and
start the daemon again.  Something that took me a long time to realize is
"chown" does not work correctly under CYGWIN
on  Windows XP.  It will change the "owner" that cygwin shows the file as
owned by.  However,
it doesn't actually effect permissions.  i.e.
      echo "hi" > foo.txt
      chmod 600 foo.txt
      chown SYSTEM foo.txt
will create a file that appears to be owned by SYSTEM and only accessible by
"SYSTEM".  However, the "SYSTEM" user will get an EPERM error when trying to
read or write the file...
So even if a file appears to have the correct ownership under "ls" and
"getfacl", it might not...
I have not figured out a way to determine the "real" owner of a file.


My script steps back and forth through the run levels.  This is
mainly to simulate the behavior I'm used to.  If everything is configured
correctly, it should be sufficient just to switch to runlevel 6 when
shutting down and to your default run level when starting up.


From: "Sanjay Goel" <>
Subject: cron in cygwin
Date: Wed, 7 May 2003 13:13:37 +0530
Message-ID: <b9ad70$hkh$>

I want to run updatedb every week ... I wrote the following in my crontab

0 22 * * 2 updatedb --localpaths="/ /c /d /e"

but it never works.

Can somebody tell me how to set cron jobs in cygwin.

Thanks in advance


Attachment: inittab
Description: Binary data

Description: Binary data

Attachment: cron
Description: Binary data

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]