{"id":1047,"date":"2017-05-18T19:32:51","date_gmt":"2017-05-18T14:32:51","guid":{"rendered":"http:\/\/alexeyka.zantsev.com\/?p=1047"},"modified":"2017-05-22T13:10:45","modified_gmt":"2017-05-22T08:10:45","slug":"linux-run-a-command-with-a-time-limit","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=1047","title":{"rendered":"Linux: run a command with a time limit"},"content":{"rendered":"<p>Need to run tcpdump at night writing to a pcap file? Not a problem with a crond.<br \/>\nNeed to stop it after 10 minutes? One more crond task initiating something like &#8216;ps aux | grep [t]cpd&#8217;, parsing it PID and killing it? No!<\/p>\n<p><code>timeout 10m tcpdump -v -pnni eth0 udp src port 5060 and dst port 5060 and host 10.11.7.1 -w pbx_`date +%F_%H-%M`.pcap<\/code><\/p>\n<p><a href=\"http:\/\/www.gnu.org\/software\/coreutils\/manual\/html_node\/timeout-invocation.html#timeout-invocation\" target=\"_blank\">timeout<\/a> &#8211; a nice GNU coreutil.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Need to run tcpdump at night writing to a pcap file? Not a problem with a crond. Need to stop it after 10 minutes? One more crond task initiating something like &#8216;ps aux | grep [t]cpd&#8217;, parsing it PID and killing it? No! timeout 10m tcpdump -v -pnni eth0 udp src port 5060 and dst [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9,232],"class_list":["post-1047","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linux","tag-timeout"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1047"}],"version-history":[{"count":2,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1047\/revisions"}],"predecessor-version":[{"id":1057,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/1047\/revisions\/1057"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}