need help with truss !

i have to gather some info about a process and redirect it to a1.txt file. For this i m using truss command

truss -po a1.txt $PID_Detail

where $PID_Detail= 1482944 3362976
--------------------------------------------------------------------------

Below the script:

#!/bin/ksh

for i in Cleaner1 Archiver1
do

PID_Detail=`ps -aef | grep java | grep "$i" | tr -s " " | cut -d cut -d " " -f3-4`
echo "$i-------->$PID_Detail"
truss -po a1.txt $PID_Detail
sleep 300
done
-------------------------------------------------------------------------

How to execute this command for 5min or 300sec inside the script.Basically my intention is to get the info about the process using truss command for a period of 300 secs inside a script. and then continue with the next process

plz help me in this ?

truss -po a1.txt $PID_Detail [2>&1 >> file] & # truss in background use strin in brackets if you want the output into a file
sleep 300
kill $! # kill the bg process

i used the below commands in sequence as u suggested:

truss -po a1.txt $PID_Detail [2>&1 >> file] & #
sleep 300
kill $! #

-------------------------------------------------------------------

but it is showing error as below

Cleaner1-------->2158680 2519258
truss: 0915-021 Invalid process id: [2.
kill: 2760708: no such process
Archiver1-------->3579956 3371106
truss: 0915-021 Invalid process id: [2.
kill: 1868006: no such process

------------------------------------------------------

can u tell me how to use the commands suggested by you ?

all text within the brackets and the brackets itself are optional
if you want trussouput in a file:
truss -po a1.txt $PID_Detail 2>&1 >> file &
if you want truss outut on the screen
truss -po a1.txt $PID_Detail &

all text within the brackets and the brackets itself are optional
if you want trussouput in a file:
truss -po a1.txt $PID_Detail 2>&1 >> file &
if you want truss outut on the screen
truss -po a1.txt $PID_Detail &

when i m doing the below command:

truss -po a1.txt $PID_Detail &
sleep 300
kill $!

----------------------------------------------------------------------------------------------------------------

here the o/p file is a1.txt i.e i m here redirecting the o/p to file a1.txt. But the above command is not killing the truss process

i m asking how to run this command in background and then kill the truss command after sleep of 300 seconds

What i do not understand is how can i break or interrupt truss after it has given the basic list of system calls for processes

When i run truss on some processes i can see that they r in sleep state waiting for an input. Using ctrl-c in command prompt i can break from the truss output. but how to achieve this in a script

still wating for the help ! Below the script i m using to truss and then kill it after 300sec. but the problem is that it is not able to kill the truss after 300 sec

for i in Cleaner1 Archiver1
do

PID_Detail=`ps -aef | grep java | grep "$i" | tr -s " " | cut -d cut -d " " -f3-4`
echo "$i-------->$PID_Detail"

truss -po a1.txt $PID_Detail &
sleep 300
kill $!
echo "Completed"
done
--------------------------------------------------------------------------------

below the o/p i m getting

Cleaner1-------->2158680 2519258
Completed
Archiver1-------->3579956 3371106
Completed
Pstatus: process is not stopped

--------------------------------------------------------------------------------------

but when i grep for truss it shows all the truss process still running in background:

ps -aef | grep -v "grep" | grep "truss"

pipe 1089784 1466410   0 23:59:15  pts/1  0:00 truss -po a1.txt 2158680 2519258 
pipe 1466410       1   0 23:59:15  pts/1  0:00 truss -po a1.txt 2158680 2519258 
pipe 2543734       1   0 23:59:20  pts/1  0:00 truss -po a1.txt 3579956 3371106 
pipe 3035362 2543734   0 23:59:20  pts/1  0:00 truss -po a1.txt 3579956 3371106