Posts Tagged ‘timeout’

Linux: run a command with a time limit

Thursday, May 18th, 2017

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 ‘ps aux | grep [t]cpd’, parsing it PID and killing it? No!

timeout 10m tcpdump -v -pnni eth0 udp src port 5060 and dst port 5060 and host -w pbx_`date +%F_%H-%M`.pcap

timeout – a nice GNU coreutil.