Last active
August 29, 2015 14:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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