GNU/Linux Command – TIMEOUT

timeout — Send a signal to a program after a certain timeout.


‘timeout’ executes a program (with arguments args) and sends a signal (like KILL, TERM etc) to it after a certain amount of seconds. It is from NetaTalk Project.

$ timeout 10 ping localhost -- Run the Ping program and send, by default, a SIGTERM after 10 seconds. $ timeout -s KILL 10 ping localhost -- Same as above. But here KILL Signal will be send to the Ping Program after 10 seconds. $ timeout -s HUP 10 sh -- Spawn a shell and send a hangup signalafter 10 seconds. $ timeout -s 1 10 sh -- Same as above. Signal #1 == HANGUP.
Read: man timeout and man 7 signal

3 thoughts on “GNU/Linux Command – TIMEOUT

  1. Hi, how can I execute a command with arguments using timeout?timeout takes command arguments as itself.I tried executing it using dead tilt but I can´t see any and timeout is not workingSorry for my english.# timeout 10 tcpdump -A -anytimeout: invalid option — AUsage: timeout [-s signal] seconds program [args]

  2. @Rene, It looks like tcpdump option is wrong. Just to verify, Plz run the 1st ping command and check the tcpdump options also.

  3. Thanks for your answer. but the -A is a valid option in tcpdump. If I run it alone, it works. I also tried timeout 1 ls -las /home and fail the same way. It does not recognized -l as an argument of "ls" command. # tcpdump -Atcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes13:16:42.736276 IP WEB-FR1-B.37640 > UDP, length: 199E…..@…$……………U.>>>t=statusst=activedt=7530 # timeout 1 ls -las /home timeout: invalid option — lUsage: timeout [-s signal] seconds program [args]You can use a numerical signal, or one of these: HUP INT QUIT ILL TRAP ABRT IOT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD CLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH USR1 USR2 PWR

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: