Freebsd, unix | mail notification about password expiration« Wróć do listy pytań

example script, shell
Wysłane przez mrmucha
Zadane przez 16/03/2021 10:22
0
#!/bin/sh
#432000 5 days

time_to_expire=0
current_timestamp=$(date +%s)
user_timestamp=0
notify_threshold=432000

for user in $(cat /etc/passwd | cut -d : -f 1)
do
 user_timestamp=$(pw showuser -n $user | cut -d: -f 6)
 time_to_expire=$(($user_timestamp-$current_timestamp))
 
 echo $user
 echo $time_to_expire
 
if [ $time_to_expire -gt 0 ] && [ $time_to_expire -lt $notify_threshold ]; then
 $(echo "Your password will expire, change it" | mail -s "Mail password expiration" $user@my.target.user.com)
fi

done | paste -d " " - -

Wysłane przez mrmucha
Odpowiedziane 16/03/2021 10:23