Notifications
Clear all
BugOverflow
1
Posty
1
Users
0
Reactions
789
Widok
0
16/03/2021 11:22 am
Topic starter
example script, shell
1 Answer
0
16/03/2021 11:23 am
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 " " - -