Skip to content

Instantly share code, notes, and snippets.

@michaelcoyote
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelcoyote/5a42af5b39866beba12a to your computer and use it in GitHub Desktop.
Save michaelcoyote/5a42af5b39866beba12a to your computer and use it in GitHub Desktop.
check for user running a program before updating and skip them if they are
#!/bin/bash
#
# Proof of concept
# check for user running a program before updating and skip them if they are
#
PROGRAM="irssi"
# Check ps for users running a process name & compare against list of non-admin users
#
upgradable_users=`comm -13 <(ps -C $PROGRAM -o fuser |grep -v USER|sort|uniq) <(awk -F: '$3 > 500 {print $1}' /etc/passwd|sort)`
for cur_user in $upgradable_users
do
#echo "fixing $cur_user 's problems with $PROGRAM"
ls -ld /home/"$cur_user"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment