Forum

Freebsd, unix | mai...
 
Notifications
Clear all

Freebsd, unix | mail notification about password expiration

1 Posty
1 Users
0 Reactions
762 Widok
0
Topic starter

example script, shell

1 Answer
0
Topic starter
#!/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 " " - -

Odpowiedź

Author Name

Author Email

Your question *

Preview 0 Revisions Saved
Share: