|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『楼 主』:
批处理检测网络状况,发现网络不通时自动重启电脑
使用 LLM 解释/回答一下
如题
如检测到网络不通,则5 分钟后自动重启电脑
谢谢
As the title.
If the network is detected to be unavailable, the computer will automatically restart after 5 minutes.
Thank you
|
|
2009-9-9 06:17 |
|
|
szweiw
新手上路

积分 18
发帖 18
注册 2009-7-27
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
:start
::把这个IP改成你用来检测网络的地址,例如网关
ping 10.10.37.254 -n 1 > nul
::-t 后面的数字就是等待多少秒后重启
if %errorlevel% neq 0 shutdown -r -t 300
goto :start
```
:start
::Change this IP to the address you use to detect the network, such as the gateway
ping 10.10.37.254 -n 1 > nul
::-t The number behind is how many seconds to wait before restarting
if %errorlevel% neq 0 shutdown -r -t 300
goto :start
```
|
|
2009-9-9 06:34 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
谢谢,刚才试了一下,挺好的
再增加一个问题,有没有一个命令可以修复网络连接呢?
我的想法是这样的:服务器本机一直运行这个P,当发现网络不通时则自动修复网络,修复完成后再自动重启电脑,主要想让服务器自己修复一下,谢谢
Thanks, I just tried it, it's quite good.
Add another question, is there a command that can repair the network connection?
My idea is like this: The server itself has been running this P. When it is found that the network is not working, it will automatically repair the network. After the repair is completed, it will automatically restart the computer. I mainly want the server to repair itself. Thanks
|
|
2009-9-9 07:29 |
|
|
szweiw
新手上路

积分 18
发帖 18
注册 2009-7-27
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
网络不通的原因有很多啊。。。这个也能自动做的话,大把网管得下岗了
There are many reasons for network disconnection... If this could be done automatically, a large number of network administrators would be out of work
|
|
2009-9-9 10:39 |
|
|
szweiw
新手上路

积分 18
发帖 18
注册 2009-7-27
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
想了一下,刚才给的代码还是不够好,在断网后会不断执行shutdown,还是应该设置跳出循环
:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
shutdown -r -t 300
goto :end
)
goto :start
:end
After thinking about it, the code provided earlier is still not good enough. After losing network connection, it will keep executing shutdown. We should set up to jump out of the loop.
:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
shutdown -r -t 300
goto :end
)
goto :start
:end
|
|
2009-9-9 13:13 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
谢谢!您这个只要一不通就重启,假如网络出现闪断时正好PING了那就不好了是吧
我觉得应该PING2分钟连续不通的时候再重启电脑,可以吗?
Thanks! You this one restarts as soon as it doesn't work. If the network flashes and breaks when it's just PINGing, that's not good, right? I think it should restart the computer when PING has been uninterrupted for 2 minutes, can that work?
|
|
2009-9-9 22:50 |
|
|
yishanju
银牌会员
     [b]看你妹啊[/b]
积分 1488
发帖 1357
注册 2006-5-20
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
这个方法明显不是保证服务器稳定,网络稳定的方法。
This method is obviously not a way to ensure server stability and network stability.
|

有问题请发论坛或者自行搜索,再短消息问我的统统是SB |
|
2009-9-9 23:06 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
但是公司不想买设备,只有自己弄个简单的了
But the company doesn't want to buy equipment, so we have to make a simple one by ourselves.
|
|
2009-9-10 02:31 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
我是这样想的
如果上面假设解决了的话
我再找一个短信发送设备,等重启电脑后网络还是不通就自动发送一条短信“某某服务器网络中断”
可行吧?
This is what I thought. If the above assumption is solved, then I will find a short message sending device. If the network is still not working after restarting the computer, it will automatically send a short message "XX server network interruption". Is it feasible?
|
|
2009-9-10 02:33 |
|
|
yishanju
银牌会员
     [b]看你妹啊[/b]
积分 1488
发帖 1357
注册 2006-5-20
状态 离线
|
|
2009-9-10 02:51 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
|
2009-9-10 04:18 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by szweiw at 2009-9-9 13:13:
想了一下,刚才给的代码还是不够好,在断网后会不断执行shutdown,还是应该设置跳出循环
:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
...
不好意思
试了一下还是死循环<img src="images/smilies/face-sad.png" align="absmiddle" border="0">
Originally posted by szweiw at 2009-9-9 13:13:
Thought about it, the code given just now is still not good enough. After losing internet connection, it will keep executing shutdown. Still, the loop should be set to break out
:start
ping 10.10.37.254 -n 1 > nul
if %errorlevel% neq 0 (
...
Sorry
Tried it, but it's still an infinite loop :(
|
|
2009-9-10 05:20 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
|
2009-9-10 05:21 |
|
|
lianruidong
新手上路

积分 10
发帖 10
注册 2009-9-7
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
你好!
可以这样吗?先PING一台机器,如果不通时再继续ping1分钟,还是不通则重启电脑,而且别是死循环的,谢谢!
Hello!
Can this be done? First ping a machine, if it's not reachable, then continue pinging for 1 minute. If it's still not reachable, then restart the computer, and it's not a dead loop, thank you!
|
|
2009-9-10 05:23 |
|