# Created on savesnippets.com · https://savesnippets.com/AzVZQyt7X9fpde # Plain — kill after 30 seconds timeout 30s curl -s https://slow.api/data # Force kill after grace period (default sends SIGTERM, then SIGKILL after 10s) timeout --kill-after=10s 30s ./long-running-job.sh # Distinguish timeout from other failures if ! timeout 5s ping -c 100 example.com; then rc=$? if [[ $rc -eq 124 ]]; then echo "Timed out" >&2 else echo "Failed with exit code $rc" >&2 fi fi