timeout

timeout - run a command with a time limit.


Execute ping command for 10 seconds and stop

timeout 10 ping www.facebook.com

Execute ping command for 1 minute and stop

timeout 1m ping www.google.com

Execute ping command for 1 hour and stop

timeout 1h ping www.yahoo.com

Execute ping command for 1 day and stop

timeout 1d ping localhost

Execute tail command for 10 minutes and exit with SIGKILL signal (forced)

timeout -s SIGKILL 10m tail -f /var/log/syslog