开发者

How to periodically create an HTTP POST request from windows

I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.

What would you recommend as the best approach for that?

The things I considered are: 1. Creating a Windows service 2. Using a script in python (I have cygwin installed) 3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute)

Thanks for any additional ideas or hints on how to be开发者_运维问答st implement it.


import urllib
import time

while True:
   urllib.urlopen(url, post_data)
   time.sleep(60)


If you have cygwin, you probably have cron - run a python script from your crontab.


This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that.

I have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to "Run whether user is logged on or not" which ensures that it runs when I'm not logged on. There's no "black cmd window".

You didn't say which version of Windows you are on and if you are on XP (unlucky for you if you are) then the configuration is probably different since the scheduled task interface changed quite a bit when Vista came out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜