tail for 15 mins

Hi,

I want to write a script which will tail a particular file for 15 mins and then sleep for 10 mins and again tail for 15 mins. This cycle will go on for a limited period of time.
How can i ensure that tail command will run for 15 mins before calling sleep command

Thanks

Hope this basic example helps.

tail -f logfile & PID=$!
sleep 900
kill $PID
tail -f logfile & PID=$!
sleep 600
kill $PID

Something like this?

#!/bin/bash

while true
do
  tail -f infile &
  pid=$!
  sleep 1500
  kill -9 $pid >/dev/null 2>&1
done

--ahamed

I don't understand what does he mean by tail for 15 mins.

try with "watch" command.

Example:
watch -n 900 "tail filename"

The "watch" command is specific to BSD, is that what your O/S is?

If I look at the OP's requirement it should be more like:

while :
do
  tail -f file & pid=$!
  sleep 900
  kill $pid
  sleep 600
done