EDITOR'S NOTE: Share your Windows and .NET discoveries, comments, problems, solutions, and experiences with products and reach out to other Windows & .NET Magazine readers (including Microsoft). Email your contributions (400 words or less) to email@example.com. Please include your phone number. We edit submissions for style, grammar, and length. If we print your submission, you'll get $100. Submissions and listings are available online at http://www.winnetmag.com/articles. Enter the InstantDoc ID number in the InstantDoc ID text box.
If you've worked with UNIX, you know how easy the OS's cron scheduler is to use. Although Windows 2000 has better scheduling functions than Windows NT has, I still don't like Win2K's scheduling. I was happy to find the AINTX toolset, which offers numerous command-line administration toolsâ€”including an NT version of cron.
The AINTX toolset is available at http://www.dwam.net/docs/aintx. You can extract the whole toolset to a directory in your path. AINTX includes a readme file that has documentation for each utility in the toolset. Alternatively, you can enter
at the command prompt to obtain help for a command.
To use the cron tool for scheduling, copy cron.exe and cron.cfg into the \%systemroot%\system32 directory. You can use the Microsoft Windows NT Server 4.0 Resource Kit's Instsvc utility to install cron as a service, but I found AINTX's Mksvc utility to be easier. The command-line syntax to install cron as a service is
mksvc -s cron -p <CronPath> -e "<ServiceName>" -a
where CronPath is the full path to the file cron.exe and ServiceName is the service's display name in the Control Panel Services applet. You can't use the Net Start command to start cron from the command line. You need to use the Services applet or the AINTXv200 toolset's startsvc utility.
To schedule a job, simply edit cron.cfg in the \%systemroot%\system32 directory. Cron.cfg includes instructions for adding jobs. Two sample job entries are
10,20,30,40,50 * * * 1-5 c:\winnt\system32\cmd.exe /c c:\winnt\test.cmd */10 * * * * 1-5 c:\winnt\system32\cmd.exe /c c:\winnt\test.cmd
Both jobs will run every 10 minutes Monday through Friday. After you make changes to the cron.cfg file, save the file. You don't need to restart the cron service for the changes to take effect. To make changes on a remote server, you just need to edit the server's cron.cfg file.