我希望能夠通過命令行有效「運行」每分鐘更新一次網站的URL。這是可能的,如果是這樣,我該怎麼做?在不通過CMD打開瀏覽器的情況下運行URL
我不希望這個命令打開瀏覽器,所以「開始」將不起作用。我只希望它每分鐘運行一次相同的URL。
我希望能夠通過命令行有效「運行」每分鐘更新一次網站的URL。這是可能的,如果是這樣,我該怎麼做?在不通過CMD打開瀏覽器的情況下運行URL
我不希望這個命令打開瀏覽器,所以「開始」將不起作用。我只希望它每分鐘運行一次相同的URL。
如果您有Windows 7或更高版本,則可以在您的shell中訪問PowerShell。現在儘管使用命令工具如curl
和wget
可能會有更高效的解決方案。你可以簡單地做在批處理文件如下:
:: Use the Out-Null under if you want to suppress output from server response
echo Updating server...
powershell -NoProfile "irm <YOUR_URL here> | Out-Null"
一個完整的實現可能看起來像
@echo off
:PingServer
echo Updating Server...
call powershell -NoProfile "irm <YOUR_URL here> | Out-Null"
ping localhost -n 60 -w 1000 > NUL
goto PingServer
注:平作爲second
基於休眠機制,因爲timeout
/sleep
在所有的Windows環境中都不可用。
一個完整的PowerShell的做法可能是:
$URL = "<your url>"
# Update the server, and additional processing if you'd want
function Update-Server {
Write-Host "Updating the server..."
irm $URL | Out-Null
}
# While loop to update server, then sleep 1 minute
while(1) {Update-Server;sleep 60}
[wget的(https://en.wikipedia.org/wiki/Wget)或[捲曲](HTTPS://curl.haxx。 se /) – fvu
這就是linux @fvu,你不能假設OP在其計算機 –
@AP上有[** _ Cygwin _ **](http://cygwin.com/)。絕對不。 [curl以bazillion預編譯的二進制版本存在,包括沒有cygwin的windos](https://curl.haxx.se/download.html)。 [wget也是](http://gnuwin32.sourceforge.net/packages/wget.htm)。不要傳播錯誤信息。 – fvu