azureuser@puppetagent-ubuntu1:/tmp$ cat /bin/user_activity.sh
#!/bin/bash
echo `last` > /tmp/login_history.txt
I'm tracking user data in linux through the "last" command so I'm appending data to .txt and .csv files but still data is not coming as format as i'm expecting.
cat out.txt
:
azureuse pts/1 157.47.38.139 Mon Sep 20 14:30 still logged in
azureuse pts/0 157.47.56.225 Mon Sep 20 12:33 - 14:34 (02:00) azureuse pts/0 157.47.56.225 Mon Sep 20 10:29 - 12:33 (02:03) azureuse pts/0 157.47.56.225 Mon Sep 20 09:53 - 10:28 (00:35) azureuse pts/0 157.47.37.28 Mon Sep 20 09:09 - 09:53 (00:43) azureuse pts/1 157.47.40.253 Mon Sep 20 05:30 - 08:51 (03:20) azureuse pts/0 157.47.40.253 Mon Sep 20 05:28 - 08:51 (03:22) azureuse pts/0 157.48.201.134 Fri Sep 17 12:15 - 16:10 (03:54) azureuse pts/0 157.48.201.134 Fri Sep 17 08:47 - 11:38 (02:50) azureuse pts/0 157.48.201.134 Fri Sep 17 06:07 - 08:17 (02:09) azureuse pts/0 157.48.139.114 Thu Sep 16 14:53 - 14:57 (00:04) azureuse pts/0 157.48.139.114 Thu Sep 16 14:48 - 14:48 (00:00) azureuse pts/0 157.48.139.114 Thu Sep 16 13:49 - 14:47 (00:58) reboot system boot 5.8.0-1041-azure Thu Sep 16 13:29 still running wtmp begins Thu Sep 16 13:29:48 2021
im expecting like below
testvm:/etc/puppetlabs/code/environments/production/manifests$ last
azureuse pts/0 104.46.119.134 Mon Sep 20 14:29 still logged in
azureuse pts/1 104.46.119.134 Mon Sep 20 09:52 - 14:35 (04: 42)
azureuse pts/0 104.46.119.134 Mon Sep 20 09:10 - 09:53 (00:42)