top -b -n 1 and a for loop ... for instance to capture
roughly an hour
Code:
for z in `seq 1 3600`; do top -b -d 1 -n 1| awk -f top.awk;sleep 1; done | tee topoutput
where top.awk looks something like this (here it would give you the
top-20 memory hogs per run - see head):
Code:
BEGIN{
command = "LC_ALL=C sort -k 10,10gr|head -20"
}
{
line[NR]=$0
last=NR
}
END{
for(i=1;i<8;i++){
print line[i]
}
for(i=8;i<last;i++){
print line[i]|& command
}
close(command, "to")
while ((command |& getline out) > 0)
print out
close(command)
}
Cheers,
Tink