view · edit · history · print

Reversed ps

 
#!/usr/bin/ksh                                                                  
function GetPPName {                                                            
PID=$1                                                                          
PRTEXT=$(ps -fp $PID -F "user pid ppid tty pcpu time vsize args"|tail +2 )      
PPID=$(echo $PRTEXT | awk '{print $3}')                                         
if [[ $PID -gt 1 ]]                                                             
  then                                                                          
  print "$PRTEXT"                                                               
  GetPPName $PPID                                                               
elif [[ $PID -eq 1 ]]                                                           
then                                                                            
  print "$PRTEXT"                                                               
  exit                                                                          
else                                                                            
exit                                                                            
fi                                                                              
}
ps -fp  1 -F  "user pid ppid tty pcpu time vsize args" |head -1                 
GetPPName $1 


 
# You switch logs at night and quickly need yesterdays file?
ls -tr |tail -2|head -1



admin · attr · attach · edit · history · print
Page last modified on June 12, 2009, at 07:16 AM