Skip to content

Instantly share code, notes, and snippets.

@jhn--
Last active January 27, 2016 10:54
Show Gist options
  • Save jhn--/519182158e3a476705ee to your computer and use it in GitHub Desktop.
Save jhn--/519182158e3a476705ee to your computer and use it in GitHub Desktop.
Grabs a list of processes currently running and saves list into /var/log/process_snapshots
#!/bin/bash
#set -x
snapshot(){
now=$(date +%F_%H:%M:%S)
ps -e -o user,uid,pid,ppid,class,rtprio,ni,pri,psr,c,pcpu,pmem,vsz,rss,start,time,etime,stat,wchan=wwwwwwwwwwwwwwwwwwwwww,cmd --sort=user | grep -Evi 'root|bash|ssh' > $where/process_$now.log;
}
go(){
where=/var/log/process_snapshots
if [ ! -d $where ]; then
/bin/mkdir $where
snapshot
else snapshot
fi
}
case "$1" in
--help)
printf "\nGrabs a list of processes currently running and saves list into /var/log/process_snapshots \n"
;;
*)
go
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment