## TITLE: BASH - LIST RUNNING PROCESSES (PS) ## OS: MAC OS 10.6.X ## LAST DOC MODIFY: 2011-11-18 $ ps -axc ################################# #!/bin/bash process_name=rsync process_number=`ps axc | grep $process_name | awk '{print $1}'` if [[ "$process_number" -ne 0 ]]; then echo "" echo "$process_name not found" exit -1 fi echo "" echo "$process_name is pid# $process_number" exit 1 ################################# ## FLAGS -a Display information about other users processes as well as your own. Will skip processes which do not have a controlling terminal, unless -x option is specified -x When displaying processes matched by other options, include processes which do not have a controlling terminal. This is the opposite of -X -X When displaying processes matched by other options, skip processes which do not have a controlling terminal -c Change command column output to just contain executable name, not full command line __________________________________________________________________________________________ Copyright 2000-2011 Dylan Schneider. All Rights Reserved. This document uses unix line breaks(LF). Text on macnode.com is for example only, not as actual working instructions. Text on macnode.com should only be used as a guide, and only by advanced it professionals.