Shell function to tail a log file for a specific string for a specific time
You can use signal handlers from shell scripts (see http://www.ibm.com/developerworks/aix/library/au-usingtraps/index.html).
Basically, you'd define a function to be called on, say, signal 17, then put a sub-script in the background that will send that signal at some later time:
timeout(pid) { sleep 1200 kill -SIGUSR1 $pid}watch_for_input() { tail -f file | grep item}trap 'echo "Not found"; exit' SIGUSR1timeout($$) &watch_for_input
Then if you reach 1200 seconds, your function is called and you can choose what to do (like signal your tail/grep combo that is watching for your pattern in order to kill it)