Find and alert user password expiry

Script to Alert User password Expiry before ten days of expiry date .

===================================================
#!/bin/sh

[email protected]
[email protected]
[email protected]

for i in user1 user2
do

# convert current date to seconds
currentdate=`date +%s`
# find expiration date of user
userexp=`chage -l $i |grep ‘Password Expires’ |cut -d: -f2`
# convert expiration date to seconds
passexp=`date -d “$userexp” +%s`
# find the remaining days for expiry
exp=`expr \( $passexp  – $currentdate \)`
# convert remaining days from sec to days
expday=`expr \( $exp / 86400 \)`
if [ $expday -le 10 ]; then
echo “Please do the necessary action”  | mailx -s “Password for $i will expire in $expday day/s” $rcvr3,$rcvr2
fi
done

### checking for root user password expiary ###

for j in  root
do
currentdate=`date +%s`
userexp=`chage -l $j |grep ‘Password Expires’ |cut -d: -f2`
passexp=`date -d “$userexp” +%s`
exp=`expr \( $passexp  – $currentdate \)`
expday=`expr \( $exp / 86400 \)`

if [ $expday -le 10 ]; then
echo “Please do the necessary action”  | mailx -s “Password for $j will expire in $expday day/s” $rcvr1
fi
done
===================================================