开发者

UNIX Script that check each minute who logs in and out?

开发者 https://www.devze.com 2023-01-25 05:41 出处:网络
can some one开发者_JS百科 please tell me, how can I checks each minute and reports on who logs in and who logs out?For starting point, take a look here:

can some one开发者_JS百科 please tell me, how can I checks each minute and reports on who logs in and who logs out?


For starting point, take a look here:

  • http://www.unix.com/shell-programming-scripting/39579-users-who-loged-within-5-minutes.html

Using who -s gives you the log in times of the users currently logged in. The link above uses a 5-minute threshold to filter the list, but you can change it to 1-minute.

You can either make a script that does the above and then sleeps for 60 seconds in a while loop or maybe use cron to set up this to run every minute (though I would prefer a script for short periods like that).

You would miss the users who logged in and out between the two script runs, though.

I guess you would need more then a script if you need a more robust solution.


You can use the "last" command to get a list of recent login history. Do you want to see the login/logouts since you last ran the script, or literally in the last minute?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号