View Full Version : [ubuntu] Password Expire Notification
hakras
March 16th, 2009, 08:38 PM
I am in need of a way to notify users when their password or account will expire. In my environment, users are running an application that automatically logs into their Ubuntu account. Therefore, users do not physically see the password or account expires warning messages. I need to find a way (script) to run a daily task that will check the password expiration and account expiration. If either is 14 days or less to expire, send them and an admin account an e-mail.
I could do this in Windows, but have no clue how to do this in Ubuntu. Does anyone know how this can be done?
telemusic
March 18th, 2009, 11:28 AM
#!/bin/bash
sec=`date +%s`
let min=$sec/60
let hr=$min/60
let day=$hr/24
#$day = number of days since 1970-01-01
for i in `ls /home` #for each user from your server
do
chday=`cat /etc/shadow | grep $i | cut -d ":" -f 3`
let dif=$day-$chday
#$chday = day (counted from 1970-01-01) of last password change
#$dif = number of days since last password change
if [ "$dif" -gt 30 ] #if password was changed more than 30 days ago
then
# here put some actions that will notify user, that he should change password - I use sendEmail, #to send mail notify
fi
done
And then put this script in crontab, to run it daily.
hakras
March 24th, 2009, 05:35 PM
I have run into an issue. I cannot send mail from this segment of the network. I've planned a work around. What I am looking to do is output the information from the script above to a text file. What would be the command to write the results to a file?
Thanks
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.