#ShellScript Timeout Snippet


Just stick a great snippet that implements Timeout in the shellscript command🙂

timeout=5                       # in seconds
ping 127.0.0.1 & cmdpid=$!      # Command to terminate
# Start "watchdog" process to terminate the command
# after $timeout seconds:
(sleep $timeout; kill -9 $cmdpid) &
watchdogpid=$!
wait $cmdpid                    # wait for command
kill $watchdogpid >/dev/null 2>&1

Courtesy : http://www.oase-shareware.org/shell/scripts/quickies/timeout

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s