#!/bin/sh if [ $# -eq 0 ]; then echo "usage: timex [ -t sec ] command" >&2 exit 1 fi interval=60 if [ "a$1" = a-t ]; then shift if [ $# -eq 0 ]; then echo "usage: timex [ -t sec ] command" >&2 exit 1 fi if [ "$1" -le 0 ]; then echo "timex -- -t specification must be > 0" >&2 exit 1 fi interval="$1" shift fi if [ $# -eq 0 ]; then echo "usage: timex [ -t sec ] command" >&2 exit 1 fi $* & pid=$! sleep $interval if kill -0 $pid > /dev/null 2>&1 ; then kill -9 $pid > /dev/null 2>&1 fi