取消
顯示結果 
搜尋替代 
您的意思是: 

定义上次登陆的用户时间

定义上次登陆的用户时间

This should be simple but it's causing me heartburn. I just want to know the

last time any of the users on my Tru64 Unix V5.1B system have logged in. The

system shows it when you actually log in so I know it's there somewhere. I

want to do this from a system management (root) level so I can look to get

rid of accounts that haven't been used in a long time.





I tried the lastlogin command. It did create a file called

/var/adm/acct/sum/loginlog, but the first column (presumably the date) is

all zero's. I tried parsing my way through /var/adm/wtmp and it doesn't even

seem like all the information is there, but in any case, it's very hard to

read.





2 回覆

定义上次登陆的用户时间

first, can you provide more specific meaning of the word 'last time'.



I am not sure if the command `lastlogin` means the same as `last`, you can use following to filter for today's login



# TODAY=`date '+%a %b %d'`;last|grep "$TODAY"|more



or if you would like to have record everyday, you can simply add in your cron like

50 23 * * * /today_login.ksh > /dev/null 2>&1



file content of the "today_login.ksh"

#!/bin/ksh

TODAY=`date '+%a %b %d'`;last|grep "$TODAY" > /log/`date '+%Y%m%d'`_login.log

定义上次登陆的用户时间

Hi Assma,



> I tried the lastlogin command. It did create a file called

> /var/adm/acct/sum/loginlog, but the first column (presumably the date) is

> all zero's.



Please using the command "/usr/sbin/acct/runacct" instead of the lastlogin!



PS: The command "finger $USER" for detailed description.



Best regards,

Richard.