ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Linux timeout命令的使用:timeout - run a command with a time limit

2020-02-20 21:08:34  阅读:321  来源: 互联网

标签:127.0 run ttl 0.1 time bytes 64 timeout Linux


timeout是一个命令行实用程序,它运行指定的命令,如果在给定的时间段后仍在运行,则终止该命令。timeout命令是GNU核心实用程序软件包的一部分,该软件包几乎安装在所有Linux发行版中。

NAME
       timeout - run a command with a time limit

SYNOPSIS
       timeout [OPTION] DURATION COMMAND [ARG]...
       timeout [OPTION]
$ timeout 5 ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=128 time=0.410 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=128 time=0.181 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=128 time=0.174 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=128 time=0.146 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=128 time=0.174 ms

$ timeout -s SIGKILL 5s ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=128 time=0.331 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=128 time=0.207 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=128 time=0.385 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=128 time=0.393 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=128 time=0.123 ms
Killed

$ timeout -s 9 5s ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=128 time=0.281 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=128 time=0.355 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=128 time=0.507 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=128 time=0.215 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=128 time=0.167 ms
Killed

$ kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGEMT       8) SIGFPE       9) SIGKILL     10) SIGBUS
11) SIGSEGV     12) SIGSYS      13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGURG      17) SIGSTOP     18) SIGTSTP     19) SIGCONT     20) SIGCHLD
21) SIGTTIN     22) SIGTTOU     23) SIGIO       24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGPWR      30) SIGUSR1
31) SIGUSR2     32) SIGRTMIN    33) SIGRTMIN+1  34) SIGRTMIN+2  35) SIGRTMIN+3
36) SIGRTMIN+4  37) SIGRTMIN+5  38) SIGRTMIN+6  39) SIGRTMIN+7  40) SIGRTMIN+8
41) SIGRTMIN+9  42) SIGRTMIN+10 43) SIGRTMIN+11 44) SIGRTMIN+12 45) SIGRTMIN+13
46) SIGRTMIN+14 47) SIGRTMIN+15 48) SIGRTMIN+16 49) SIGRTMAX-15 50) SIGRTMAX-14
51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9
56) SIGRTMAX-8  57) SIGRTMAX-7  58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4
61) SIGRTMAX-3  62) SIGRTMAX-2  63) SIGRTMAX-1  64) SIGRTMAX

$ timeout -k 2s 1m ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=128 time=0.296 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=128 time=0.160 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=128 time=0.121 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=128 time=0.146 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=128 time=0.160 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=128 time=0.525 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=128 time=0.142 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=128 time=0.178 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=128 time=0.516 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=128 time=0.148 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=128 time=0.134 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=128 time=0.145 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=128 time=0.169 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=128 time=0.165 ms
64 bytes from 127.0.0.1: icmp_seq=14 ttl=128 time=0.181 ms
64 bytes from 127.0.0.1: icmp_seq=15 ttl=128 time=0.172 ms
64 bytes from 127.0.0.1: icmp_seq=16 ttl=128 time=0.141 ms
64 bytes from 127.0.0.1: icmp_seq=17 ttl=128 time=0.166 ms
64 bytes from 127.0.0.1: icmp_seq=18 ttl=128 time=0.185 ms
64 bytes from 127.0.0.1: icmp_seq=19 ttl=128 time=0.163 ms
64 bytes from 127.0.0.1: icmp_seq=20 ttl=128 time=0.153 ms
64 bytes from 127.0.0.1: icmp_seq=21 ttl=128 time=0.157 ms
64 bytes from 127.0.0.1: icmp_seq=22 ttl=128 time=0.165 ms
64 bytes from 127.0.0.1: icmp_seq=23 ttl=128 time=0.148 ms
64 bytes from 127.0.0.1: icmp_seq=24 ttl=128 time=0.119 ms
64 bytes from 127.0.0.1: icmp_seq=25 ttl=128 time=0.172 ms
64 bytes from 127.0.0.1: icmp_seq=26 ttl=128 time=0.177 ms
64 bytes from 127.0.0.1: icmp_seq=27 ttl=128 time=0.189 ms
64 bytes from 127.0.0.1: icmp_seq=28 ttl=128 time=0.143 ms
64 bytes from 127.0.0.1: icmp_seq=29 ttl=128 time=0.163 ms
64 bytes from 127.0.0.1: icmp_seq=30 ttl=128 time=0.155 ms
64 bytes from 127.0.0.1: icmp_seq=31 ttl=128 time=0.156 ms
64 bytes from 127.0.0.1: icmp_seq=32 ttl=128 time=0.275 ms
64 bytes from 127.0.0.1: icmp_seq=33 ttl=128 time=0.361 ms
64 bytes from 127.0.0.1: icmp_seq=34 ttl=128 time=0.379 ms
64 bytes from 127.0.0.1: icmp_seq=35 ttl=128 time=0.116 ms
64 bytes from 127.0.0.1: icmp_seq=36 ttl=128 time=0.210 ms
64 bytes from 127.0.0.1: icmp_seq=37 ttl=128 time=0.157 ms
64 bytes from 127.0.0.1: icmp_seq=38 ttl=128 time=0.148 ms
64 bytes from 127.0.0.1: icmp_seq=39 ttl=128 time=0.192 ms
64 bytes from 127.0.0.1: icmp_seq=40 ttl=128 time=0.143 ms
64 bytes from 127.0.0.1: icmp_seq=41 ttl=128 time=0.183 ms
64 bytes from 127.0.0.1: icmp_seq=42 ttl=128 time=0.185 ms
64 bytes from 127.0.0.1: icmp_seq=43 ttl=128 time=0.181 ms
64 bytes from 127.0.0.1: icmp_seq=44 ttl=128 time=0.162 ms
64 bytes from 127.0.0.1: icmp_seq=45 ttl=128 time=0.187 ms
64 bytes from 127.0.0.1: icmp_seq=46 ttl=128 time=0.165 ms
64 bytes from 127.0.0.1: icmp_seq=47 ttl=128 time=0.146 ms
64 bytes from 127.0.0.1: icmp_seq=48 ttl=128 time=0.138 ms
64 bytes from 127.0.0.1: icmp_seq=49 ttl=128 time=0.175 ms
64 bytes from 127.0.0.1: icmp_seq=50 ttl=128 time=0.154 ms
64 bytes from 127.0.0.1: icmp_seq=51 ttl=128 time=0.162 ms
64 bytes from 127.0.0.1: icmp_seq=52 ttl=128 time=0.169 ms
64 bytes from 127.0.0.1: icmp_seq=53 ttl=128 time=0.146 ms
64 bytes from 127.0.0.1: icmp_seq=54 ttl=128 time=0.170 ms
64 bytes from 127.0.0.1: icmp_seq=55 ttl=128 time=0.189 ms
64 bytes from 127.0.0.1: icmp_seq=56 ttl=128 time=0.183 ms
64 bytes from 127.0.0.1: icmp_seq=57 ttl=128 time=0.165 ms
64 bytes from 127.0.0.1: icmp_seq=58 ttl=128 time=0.176 ms
64 bytes from 127.0.0.1: icmp_seq=59 ttl=128 time=0.194 ms

 

Koma_Wong 发布了598 篇原创文章 · 获赞 285 · 访问量 50万+ 他的留言板 关注

标签:127.0,run,ttl,0.1,time,bytes,64,timeout,Linux
来源: https://blog.csdn.net/Rong_Toa/article/details/104417786

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有