-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogcheck.sh
40 lines (37 loc) · 856 Bytes
/
logcheck.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#script to check the time taken to login the user.
echo "Enter the username: \c"
read logname
#checking by if block username is exist.
grep "$logname" /etc/passwd > /dev/null
if [ $? -eq 0 ]
then
echo "Wait..."
else
echo "User not found."
exit
fi
time=0
while true
do
who | grep "$logname" > /dev/null
if [ $? -eq 0 ]
then
echo "$logname has logged in."
if [ $time -ne 0 ]
then
if [ $time -gt 60 ]
then
min=`expr $time / 60`
sec=`expr $time % 60`
echo "$logname was $min minutes and $sec second late in logging in."
else
sec=$time
echo "$logname was $sec second late in logging in."
fi
fi
exit
else
time=`expr $time + 1`
sleep 1
fi
done