Get last login date for all users & Active users


As we try to show occ command user:lastseen , we cloud find an user last login as below.


How can we use this command for all user? Please kindly advise. Thank you in advance.

I just needed it today and wrote this small script. Make change accordingly and use it



cd $nextcloud_dir
sudo -u apache php occ user:list > $input

while IFS= read -r line
  username=`echo "$line" | awk '{ gsub(":",""); print $2}'`
  last_login=`sudo -u apache php occ user:lastseen $username |  awk '{ print $4 "-" $5'}`
echo "$line - $last_login" 
done < "$input"

Thank you for your information. We have tried it with OCC Web function,

which we just enabled in App

Is there any way we can do that command for all user via this OCC Web or not?

Thank you for your kind always support.

Its a bash script I posted, it wont work in OCC web session. You need to run it from SSH terminal. OCC web can just run occ commands.

das funktioniert soweit gut.
Aber bei einer Anmeldung als Anton Meier gibt es Probleme.
Kannst Du bitte es nochmal überprüfen?
Schön wäre es wenn man es auch anschließend als cron job laufen lassen kann um es bei Zeiten per Mail zu schicken

Danke im voraus