我想這一點:如何查找過去24小時內連接到服務器的用戶?
sojjan pts/9 localhost Thu Oct 13 08:04:14 2016 - Thu Oct 13 08:04:15 2016 (00:00)
gurra pts/9 localhost Wed Oct 12 15:36:00 2016 - Wed Oct 12 15:36:02 2016 (00:00)
sojjan pts/8 :0 Wed Oct 12 10:13:34 2016 still logged in
sojjan pts/7 :0 Mon Oct 10 13:34:56 2016 still logged in
變成這個樣子:
Last 24h SSH logins:
sojjan pts/9 localhost Thu Oct 13 08:04:14 2016 - Thu Oct 13 08:04:15 2016 (00:00)
gurra pts/9 localhost Wed Oct 12 15:36:00 2016 - Wed Oct 12 15:36:02 2016 (00:00)
Still logged in:
sojjan pts/8 :0 Wed Oct 12 10:13:34 2016 still logged in
sojjan pts/7 :0 Mon Oct 10 13:34:56 2016 still logged in
我嘗試作爲
#!/bin/bash
test0=$(last -F | grep still)
test1=$(date | awk {'print $2, $3'});
test2=$(date --date='-1 days' | awk {'print $2, $3'});
last -F | grep -v 'reboot' | grep -i "$test0\|$test1\|$test2"
謝謝穆斯塔法和fedorqui。我對此很新。 –
但我不知道如何將這些信息提供給工作腳本。 heee –
@Larsvontrierpung然後你必須自己做一些研究。我們不是在這裏爲你餵食,而是爲了幫助。試試看,回來後回答具體問題。 – fedorqui