Log off specific users

From Michael's Information Zone
Jump to navigation Jump to search
for user in user1 user2 user3 ;
do
id=$(query user $user 2>> /dev/null | awk '{ print $3 }' | sed -e '/ID/ d')
if [[ "$id" =~ ^[1-9][0-9]?$ ]]; then
logoff $id
echo date "$user was logged off" >> logg_off.log
fi
done