在DOS / BAT中模拟睡眠

在“你能做得更好”这个问题上,这里是我使用“ping”来模拟DOS / BAT脚本中的睡眠。如果可以使用ping,则多播地址将是有效的,但不会响应。通过只做一个ping(-n 1)并设置一个以毫秒为单位的超时(-w 10000),你就有一个相当准确的计时器。这个例子给出了10秒的睡眠时间。
.

0

linux命令:ping -n 1 -w 10000 224.0.0.0 224.0.0.0 10000 -w 1 -n ping ping -n 1 -w 10000 224.0.0.0rootopen.com
linux命令:ping -n 1 -w 10000 224.0.0.0 224.0.0.0 10000 -w 1 -n ping ping -n 1 -w 10000 224.0.0.0rootopen.com
jklm 2018-03-22 01:50:48
输出
linux命令:ping 详解
替代方案1 在DOS / BAT中模拟睡眠

在Windows环境中不存在的情况下启用“睡眠”功能,尽管时间不准确。 (每个ping都有一个延迟)这是一个简单的方法来将命令与时间段分开。.

linux命令:echo sleep() begins: %TIME% && FOR /l %a IN (10,-1,1) do (ECHO 1 >NUL %as&ping -n 2 -w 1 127.0.0.1>NUL) && echo sleep() end: %TIME% %TIME% end: sleep() echo && 127.0.0.1>NUL) 1 -w 2 -n %as&ping >NUL 1 (ECHO do (10,-1,1) IN %a /l FOR && %TIME% begins: sleep() echo echo sleep() begins: %TIME% && FOR /l %a IN (10,-1,1) do (ECHO 1 >NUL %as&ping -n 2 -w 1 127.0.0.1>NUL) && echo sleep() end: %TIME%rootopen.com
linux命令:echo sleep() begins: %TIME% && FOR /l %a IN (10,-1,1) do (ECHO 1 >NUL %as&ping -n 2 -w 1 127.0.0.1>NUL) && echo sleep() end: %TIME% %TIME% end: sleep() echo && 127.0.0.1>NUL) 1 -w 2 -n %as&ping >NUL 1 (ECHO do (10,-1,1) IN %a /l FOR && %TIME% begins: sleep() echo echo sleep() begins: %TIME% && FOR /l %a IN (10,-1,1) do (ECHO 1 >NUL %as&ping -n 2 -w 1 127.0.0.1>NUL) && echo sleep() end: %TIME%rootopen.com
.
输出

评论

相关推荐

linux命令:ping rootopen.com | while read LINE; do echo $(date): $LINE; done done $LINE; $(date): echo do LINE; read while | rootopen.com ping ping rootopen.com | while read LINE; do echo $(date): $LINE; donerootopen.com
linux命令:ping rootopen.com | while read LINE; do echo $(date): $LINE; done done $LINE; $(date): echo do LINE; read while | rootopen.com ping ping rootopen.com | while read LINE; do echo $(date): $LINE; donerootopen.com
.

ping命令用于确定网络(或Internet)上主机之间的连接:

linux命令:ping google.com google.com ping ping google.comrootopen.com
linux命令:ping google.com google.com ping ping google.comrootopen.com
.

三通(如“T”连接)命令对于将输出重定向到两个地方非常有用。

linux命令:ping google.com | tee ping-output.txt ping-output.txt tee | google.com ping ping google.com | tee ping-output.txtrootopen.com
linux命令:ping google.com | tee ping-output.txt ping-output.txt tee | google.com ping ping google.com | tee ping-output.txtrootopen.com
.

平机一次,等待1秒钟,直到失败。一旦失败,全球ssh,否则本地ssh。

linux命令:ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globalip globalip ssh || localip ssh && /dev/null &> 1 -W 1 -c localip ping ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globaliprootopen.com
linux命令:ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globalip globalip ssh || localip ssh && /dev/null &> 1 -W 1 -c localip ping ping localip -c 1 -W 1 &> /dev/null && ssh localip || ssh globaliprootopen.com
.

在Linux和Mac系统上(我还没有使用其他Unix系统进行测试),ping命令将继续执行ping操作,直到用户用Ctrl + C中断为止。在Windows系统上,ping将执行多次,然后退出。 Linux和Mac上的-c标志将会发生这种情况

linux命令:ping -c 10 hostname hostname 10 -c ping ping -c 10 hostnamerootopen.com
linux命令:ping -c 10 hostname hostname 10 -c ping ping -c 10 hostnamerootopen.com
.

等待您的服务器完成重新启动?发出上面的命令,当它联机时你会听到一声哔哔声。 -i 60标志告诉ping在ping之间等待60秒,从而减轻系统负担。根据你的需要改变它。 -a标志告诉ping在收到包裹时(即服务器联机时)在输出中包含可听铃声。

linux命令:ping -i 60 -a IP_address IP_address -a 60 -i ping ping -i 60 -a IP_addressrootopen.com
linux命令:ping -i 60 -a IP_address IP_address -a 60 -i ping ping -i 60 -a IP_addressrootopen.com
.

当在Mac上运行时,当服务器HOSTNAME首先响应ping时,此命令将在终端中显示一个对话框。

linux命令:ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1' 1' button default time" about "It?s buttons up" is "Server dialog display to "Terminal" app 'tell -e osascript && HOSTNAME 30 -i -o ping ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1'rootopen.com
linux命令:ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1' 1' button default time" about "It?s buttons up" is "Server dialog display to "Terminal" app 'tell -e osascript && HOSTNAME 30 -i -o ping ping -o -i 30 HOSTNAME && osascript -e 'tell app "Terminal" to display dialog "Server is up" buttons "It?s about time" default button 1'rootopen.com
.

如果品牌X服务器停机,小丑需要一封电子邮件。使用此行每5分钟设置一个cron作业,并在/ ping时间超过3秒时收到一封电子邮件。

linux命令:ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk joker@jp.co.uk unavailable' -s'Server -ne mail | failed ping brandx.jp.sme echo || /dev/null 2&>1 brandx.jp.sme -w3 -c1 -q ping ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.ukrootopen.com
linux命令:ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.uk joker@jp.co.uk unavailable' -s'Server -ne mail | failed ping brandx.jp.sme echo || /dev/null 2&>1 brandx.jp.sme -w3 -c1 -q ping ping -q -c1 -w3 brandx.jp.sme 2&>1 /dev/null || echo brandx.jp.sme ping failed | mail -ne -s'Server unavailable' joker@jp.co.ukrootopen.com
.

linux命令:ping www.facebook.com www.facebook.com ping ping www.facebook.comrootopen.com
linux命令:ping www.facebook.com www.facebook.com ping ping www.facebook.comrootopen.com
.

该命令仅检查给定eth的网络连接。如果您在服务器或笔记本电脑中使用多个界面,这非常有用。

linux命令:ping -I eth0 www.yahoo.com www.yahoo.com eth0 -I ping ping -I eth0 www.yahoo.comrootopen.com
linux命令:ping -I eth0 www.yahoo.com www.yahoo.com eth0 -I ping ping -I eth0 www.yahoo.comrootopen.com
.

#首先安装arp-scan,如果没有itarp-scan 10.1.1.0/24 ....在localnetawk中显示ip + mac'/ 00:1b:11:dc:a9:65 / {print $ 1}'....获得与MAC相关的IP`反向使命令替换将ip传递给命令ping

linux命令:ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'` $1}'` {print '/00:1b:11:dc:a9:65/ awk | 10.1.1.0/24 `arp-scan 2 -c ping ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'`rootopen.com
linux命令:ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'` $1}'` {print '/00:1b:11:dc:a9:65/ awk | 10.1.1.0/24 `arp-scan 2 -c ping ping -c 2 `arp-scan 10.1.1.0/24 | awk '/00:1b:11:dc:a9:65/ {print $1}'`rootopen.com
.

出于某种原因,2&> 1不适合我,但较短的stdout / stderr重定向>&完美工作(Ubuntu 10.04)。

linux命令:ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.com admin@example.com unavailable' -s'Server -ne mail | failed ping server.example.com echo || /dev/null >& server.example.com -w3 -c1 -q ping ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.comrootopen.com
linux命令:ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.com admin@example.com unavailable' -s'Server -ne mail | failed ping server.example.com echo || /dev/null >& server.example.com -w3 -c1 -q ping ping -q -c1 -w3 server.example.com >& /dev/null || echo server.example.com ping failed | mail -ne -s'Server unavailable' admin@example.comrootopen.com
.

获取主机名的IP。

linux命令:ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -o -m1 egrep | google.com 1 -c ping ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'rootopen.com
linux命令:ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -o -m1 egrep | google.com 1 -c ping ping -c 1 google.com | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'rootopen.com
.

即使退出shell,仍继续在后台执行该命令。

linux命令:ping -i1 www.google.com &> /dev/null & disown disown & /dev/null &> www.google.com -i1 ping ping -i1 www.google.com &> /dev/null & disownrootopen.com
linux命令:ping -i1 www.google.com &> /dev/null & disown disown & /dev/null &> www.google.com -i1 ping ping -i1 www.google.com &> /dev/null & disownrootopen.com
.

是否可以ping通某个URL或主机,并只回应响应时间。我使用它,与MRTG监视到各种主机的连接。

linux命令:ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}' $2}' '{print -F"=" /usr/bin/awk | 2' < 'NR /usr/bin/awk | 1' > 'NR /usr/bin/awk | $7}' '{print /usr/bin/awk | www.google.com 1 -c ping ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'rootopen.com
linux命令:ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}' $2}' '{print -F"=" /usr/bin/awk | 2' < 'NR /usr/bin/awk | 1' > 'NR /usr/bin/awk | $7}' '{print /usr/bin/awk | www.google.com 1 -c ping ping -c 1 www.google.com | /usr/bin/awk '{print $7}' | /usr/bin/awk 'NR > 1' | /usr/bin/awk 'NR < 2' | /usr/bin/awk -F"=" '{print $2}'rootopen.com
.

linux命令:ping -q -c 1 www.google.com|tail -1|cut -d/ -f5 -f5 -d/ -1|cut www.google.com|tail 1 -c -q ping ping -q -c 1 www.google.com|tail -1|cut -d/ -f5rootopen.com
linux命令:ping -q -c 1 www.google.com|tail -1|cut -d/ -f5 -f5 -d/ -1|cut www.google.com|tail 1 -c -q ping ping -q -c 1 www.google.com|tail -1|cut -d/ -f5rootopen.com
.

linux命令:ping -q -c 1 www.google.com|awk -F/ 'END{print $5}' $5}' 'END{print -F/ www.google.com|awk 1 -c -q ping ping -q -c 1 www.google.com|awk -F/ 'END{print $5}'rootopen.com
linux命令:ping -q -c 1 www.google.com|awk -F/ 'END{print $5}' $5}' 'END{print -F/ www.google.com|awk 1 -c -q ping ping -q -c 1 www.google.com|awk -F/ 'END{print $5}'rootopen.com
.

8.8.8.8和8.8.4.4是两个Google公共DNS。由于它们的地址非常简单,因此使用此命令可以轻松测试Internet是否可访问。但是,要注意大型企业网络,它可能会在路由器的环回接口上使用此地址。

linux命令:ping 8.8.8.8 8.8.8.8 ping ping 8.8.8.8rootopen.com
linux命令:ping 8.8.8.8 8.8.8.8 ping ping 8.8.8.8rootopen.com
.

pcspkr必须启用!modprobe pcspkrxset b on

linux命令:ping -a IP-ADDRESS IP-ADDRESS -a ping ping -a IP-ADDRESSrootopen.com
linux命令:ping -a IP-ADDRESS IP-ADDRESS -a ping ping -a IP-ADDRESSrootopen.com
.

ping时间戳

linux命令:ping HOSTNAME | while read pong; do echo "$(date): $pong"; done done $pong"; "$(date): echo do pong; read while | HOSTNAME ping ping HOSTNAME | while read pong; do echo "$(date): $pong"; donerootopen.com
linux命令:ping HOSTNAME | while read pong; do echo "$(date): $pong"; done done $pong"; "$(date): echo do pong; read while | HOSTNAME ping ping HOSTNAME | while read pong; do echo "$(date): $pong"; donerootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令