WeBWorK Main Forum

Q: how to list current logins

Q: how to list current logins

by Dick Lane -
Number of replies: 3
After installing some security upgrades to my OS, I need to reboot my server.  I would like to do that when there are no students logged-in to Webwork.

I have a vague memory of Webwork 1.9 providing a way for me to see a list of active logins (for system or for course), but I have not found an easy way to do that with Webwork 2.4.  My current thought is to look at time-stamps for timing.log and the course transaction logs --- perhaps even doing a tail on each and checking times for individual lines (and finding "logout" as last entry in timing.log).  If there is a simpler (or more reliable) way to do this task, I will welcome suggestions.

dick lane
In reply to Dick Lane

Re: Q: how to list current logins

by Wojciech Komornicki -
If you have only a few classes, you can go into the class web site and look at the classlist editor. There the students who are logged in are marked as active.

Wojciech Komornicki
In reply to Wojciech Komornicki

Re: Q: how to list current logins

by Robert Byerly -
At one time Nandor Sieben posted a script that gets active logins. (Or at least those logins that haven't timed out.) Below is the version we are using. (I don't remember if I had to modify it slightly or not.)
Bob Byerly


# Prints a list of active webwork users. Assumes sql_single layout.
# Author: Nandor Sieben

$password = 'XXXXXX'; #your password here

sub mysql {
my ($sql) = @_;
# print "$sql";
qx[mysql -s -u webworkWrite -p$password webwork << EOF

@tables= mysql(q[show tables like '%key';]);


foreach $table (@tables) {
chop $table;
@rows=mysql(qq[select user_id, timestamp from $table]);
foreach $row (@rows) {
if ( $row =~ /(\S+)\s+(\S+)/)
$age =($ctime - $stamp) / 60;
if ($age < 10)
$table =~ s/_key//;
print "$table\t $name\t $age\n";

In reply to Robert Byerly

Re: Q: how to list current logins

by Dick Lane -
Several courses on my development machine have a name including "-" and this script terminates with "ERROR 1064 (42000)" messages mentioning each of them.

On the other hand, it works well on my production server (which has no hyphenated course-names) --- thanks Bob (and Nandor and Wojciech).