Linux run a command with a time limit

Originally published at: https://www.cyberciti.biz/faq/linux-run-a-command-with-a-time-limit/

I want to start command called foo, and kill it if still running after given DURATION in seconds. How do I run a command a time Limit on Linux? How do I run a Linux command, and have it timeout (abort) after N seconds?


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki