![显示今天在两个日期之间登录的用户](https://linux22.com/image/205925/%E6%98%BE%E7%A4%BA%E4%BB%8A%E5%A4%A9%E5%9C%A8%E4%B8%A4%E4%B8%AA%E6%97%A5%E6%9C%9F%E4%B9%8B%E9%97%B4%E7%99%BB%E5%BD%95%E7%9A%84%E7%94%A8%E6%88%B7.png)
我有两个时间,例如:12:48和16:29。如何列出12:48到16:29登录的用户?
答案1
使用带有and或标志的last
命令:-s
-t
-p
-s, --since <time> display the lines since the specified time
-t, --until <time> display the lines until the specified time
-p, --present <time> display who were present at the specified time
last -s "12:48" -t "16:29"
last -p "12:48"
请注意,第一个命令不会显示当前登录!
TIME FORMATS
The options that take the time argument understand the following formats:
YYYYMMDDhhmmss
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD hh:mm (seconds will be set to 00)
YYYY-MM-DD (time will be set to 00:00:00)
hh:mm:ss (date will be set to today)
hh:mm (date will be set to today, seconds to 00)
now
yesterday (time is set to 00:00:00)
today (time is set to 00:00:00)
tomorrow (time is set to 00:00:00)
+5min
-5days