Как анализировать/фильтровать “последнюю” команду для отображения логинов определенной даты в Ubuntu 14.04?

Я хочу проанализировать действия со входом olny текущей текущей даты. Последняя команда предоставляет мне несколько строк и столбцов. Как я фильтрую его или даже анализирую его в Python?

Любая справка будет цениться.

0
задан 18 August 2017 в 04:47

2 ответа

last предложения следующие опции для этого:

-s, --since time
              Display  the  state of logins since the specified time.  This is useful, e.g., to easily determine who was logged in at a particular time.
              The option is often combined with --until.
-t, --until time
              Display the state of logins until the specified time.
-p, --present time
              Display the users who were present at the specified time.  This is like using the options --since and --until together with the same time.

О время формат, в странице справочника говорится:

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

Здесь некоторые примеры:

last -s 2017-08-04           # from 2017-08-04 until today
last -s yesterday -t -120min # from yesterday until two hours ago
last -s -4days -t -2days     # from four days ago until two days ago
last -p 2017-08-04           # users present at 2017-08-04 00:00:00

Read больше приблизительно last и его опции на страница справочника .

2
ответ дан 2 November 2019 в 10:13

Вы можете направить выходной сигнал от last до grep. Если вы хотите видеть все входы в систему с пятницы 4 августа, используйте:

last | grep 'Fri Aug [ ]*4'

Адаптируйте вашу строку даты в grep соответственно, если вы хотите просмотреть другие даты.

1
ответ дан 2 November 2019 в 10:13

Другие вопросы по тегам:

Похожие вопросы: