Logging Script

Write a shell script that reports the logging in of a specified user within one minute after he/she logs in. The script automatically terminates if the specified user does not login during a specified period of time.

Questions by pankajforall2003

Showing Answers 1 - 3 of 3 Answers

at command to execute the script at a specified time
Duration is assumesd as 150 minutes

at -k -f log_chck -t 1008041555.00

Contents of log_chck script

 #!/bin/ksh
 # Check if the user is logged in within 100 minutes of the script start

 tim=`date +%H%M`
 for name in `who |awk '{print $1}'`
 do
   if [ "$name"  = "appla" ];then
      mailx -s "Appla logged in" -r"email_ID" email_ID<<HERE
      Hi,

      Sumeet has logged in the system.

      Regards
      System
 HERE
      ind=1
      break
   fi
   tim1=`date +%H%M`
   let tim1=$tim-$tim1
   if [ $tim1 -eq 150 ];then
      break;
   fi
 done
exit0

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions