1829398 Members
1410 Online
109991 Solutions
New Discussion

Shell scripts

 
ShivKumar_1
Frequent Advisor

Shell scripts

Hi Experts
I am trying to write a script which calculates the difference between the two dates and gives it as the number of days say for Eg: between today 4/18/01 and 3/18/01 its 30 days.
My aim is to monitor the last login time of a user and compare it with the system date and in case its more than 60 days I want to send a alert saying user has been idle. My client runs a NIS environment and he doesnt havee trusted systems. I have tried writing the following script below, can you pl guide me and let me know if its the correct way?

Thnks in advance
Shiv
_______________________________________________

#! /bin/sh
OL=`TZ=PST+1440 date +%m%d`
TO=`date +%m%d`
LST=`last -1 karin | awk '{print $6}'`
MON=`last -1 karin | awk '{print $5}'`
case $MON in
Jan) MO=01;;
Feb) MO=02;;
Mar) MO=03;;
Apr) MO=04;;
May) MO=05;;
Jun) MO=06;;
Jul) MO=07;;
esac
CK=$MO$LST
echo Last Login Date $CK
if [ $OL -lt $MO ]
then
echo This user has not loged last 60 days;
echo This user has to be deleted ;
else
echo User logged within 60 days;
fi
2 REPLIES 2
melvyn burnard
Honored Contributor

Re: Shell scripts

You would be better posting this query in the HP-UX forum as this forum is meant for hardware queries.
My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
Vincenzo Restuccia
Honored Contributor