Track Your Linux Login & Logout

To track your Linux system  when it login and when it get logout.
For this you have to add a easy script in your Linux.

First you have to create a file .login .logout which is hidden, then add a below script.

In .login file.

echo login time `date` >> .loginday/masterlog
grep -i "sun" .loginday/masterlog > .loginday/sunday.log
grep -i "mon" .loginday/masterlog > .loginday/monday.log
grep -i "tue" .loginday/masterlog > .loginday/tuesday.log
grep -i "wen" .loginday/masterlog > .loginday/wensday.log
grep -i "thu" .loginday/masterlog > .loginday/thursday.log
grep -i "fri" .loginday/masterlog > .loginday/friday.log
grep -i "sat" .loginday/masterlog > .loginday/saturday.log

In .logout file

echo logout time `date`>> .loginday/masterlog

This script is in hidden directory .loginday , you have also to give a root ownership of the directory change the mode into.

chmod 744 .loginday

Thanks

2 comments
0 likes
Prev post: Linux Tasks AlertNext post: Modifies files date and times

Related posts

Comments

  • 容网

    April 24, 2018 at 7:10 am
    Reply

    IT IS A GOOD BLOG!

  • tegang

    May 1, 2018 at 12:59 pm
    Reply

    相当精彩的博客,羡慕哦!

Leave a Reply

Your email address will not be published. Required fields are marked *

Aidbs Gallery
Latest Posts
Categories
Archives