#!/bin/sh # # pschanges - list processes and compare with the previous time we ran # # $Id# NEW=`mktemp pschanges-XXXXX` OLD=$HOME/.pschanges Die() { echo "$@" 1>&2 exit 1 } Ps() { ps -e -o user,pid,ppid,cmd | awk '$2 != "'$$'" && $3 != "'$$'" {print}' # exclude myself } Ps > $NEW || Die cannot save ps result to $NEW diff -NdU0 $NEW $OLD | awk ' /^[-+][^-+x]/ && $2 != "'$$'" && $3 != "'$$'" {print}' mv $NEW $OLD || Die cannot save ps result to $OLD