I would like to list the last 3 logins on conky so it would look something like this

username 1/1/2018 12:15 - 12:21  (00:06) 

The format can very.


You can run a shell script from conky with execi followed by the time to wait between reruns:

${execi 30 last | awk '
 /^wtmp begins/{ print s[(i+1)%3]"\n"s[(i+2)%3]"\n"s[i]; exit } 
 /^reboot /{ next }
 NF>0{ i=(i+1)%3; s[i]=$0;}'

The above, for example, runs the last command every 30 seconds, and keeps the last 3 lines seen which do not begin reboot, and writes them out when we see a line beginning wtmp begins, which marks the end of the output from last.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.