views:

2082

answers:

4

I wrote a script in Ruby. I'd like to run it every day at a certain time. How do you do that on a Windows XP system?

I poked around on the machine and discovered the "scheduled tasks" control panel, but it doesn't seem to have anything to do with running scripts, as far as I can tell from the options offered by the "wizard".

+3  A: 

You can do it with scheduled tasks, just browse for the program or script you want to run if it isn't listed (in this case, the ruby interpreter I guess, and add the name of the script to run as an argument).

frankodwyer
+4  A: 

Scheduled Tasks. Sometimes, you have to make a batch file call the script, and schedule the batch.

say you have "script.vbs" you want to run, you will have to create this batch:

cscript script.vbs

cscript is the windows script host which interprets the vbs script. I'm sure ruby has something similar.

scottm
+2  A: 

Use the Windows task scheduler.

Under Control Panel > Schedule Tasks.

You can set it up to run any application or file executable from the command line.

Update: (1/15/09) A good point from Wouter van Nifterick, remember to take care that the process finishes before the next one runs (in comments).

This can be done by going into the advanced options and adjust the allowed amount of time the task may run. If the task is already configured open it and click the Settings tab. At the top of this tab you will see a checkbox followed by 'Stop the task if it runs for:' then there are two text boxes to enter hours and minutes. If your script runs once a day you will want this set to 23 hours or so.

Brettski
Remember to take care that the process finishes, or that no new process is started until the old one finished.I've once had a server crash because some stupid script hung and was started repeatedly until windows ran out of memory and died.
Wouter van Nifterick
A: 

The 'at' command is a nice command line version of a scheduler.

Nathan