Get users last login date

HI
im looking for an app or cli command to get all users access to nextcloud in the last month in a report or list with user ID and date.

Tnx

1 Like

You can use occ user:lastseen <user> to see information about the last login of a user. With a small script which loops through the user list you could fetch this information for all users.
You can also activate the admin_audit which allows to enable a separate audit log from which you can fetch more information.

Read also

Number of active users over time

I tried the “`occ user:lastseen ”```

But I need that log for all users logged in for the last month.

image001.jpg

image002.png

image003.png

image004.png

image005.png

image006.png

You can use occ user:list to get the list of the available users and the rest should be an easy task.

Do you know feature of normal userlist (/index.php/settings/users) and activate “show last login” in Settings (at the left bottom corner)? Then normal userlist shows it and you can sort it by last login date:

1 Like

func_userlastlogin() {
> /tmp/lastseen.txt
ncuser=()
echo “be patient … reading lastseen info from user list”;echo
readarray -t ncuser <<< “$(sudo -u apache /bin/php /var/www/html/nextcloud/occ user:list|awk ‘{print $2}’)”
y=0
for i in ${ncuser[*]}
do
user=${i%?}
lastseen="$(sudo -u apache /bin/php /var/www/html/nextcloud/occ user:lastseen $user)"
echo $lastseen >> /tmp/lastseen.txt
done
cat /tmp/lastseen.txt|sort -k 3,3
}

2 Likes

While I would like to get a lot more information that this, before the last update at least I could see the latest login time on the admins users page, what has happened to that now?

It’s still there. Check settings in the bottom left hand corner and select the “show last login” check box.

Screenshot 2022-12-01 at 15.45

2 Likes