Forum

Freebsd, unix | mai...
 
Powiadomienia
Wyczyść wszystko

Freebsd, unix | mail notification about password expiration

1 Wpisy
1 Użytkownicy
0 Reactions
879 Widoki
0
Rozpoczynający temat

example script, shell

1 odpowiedź
0
Rozpoczynający temat
#!/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 " " - -

Twoja odpowiedź

Nazwa autora

E-mail autora

Twoje zapytanie *

Podgląd 0 rewizje Zapisano
Udostępnij: