caclulate total log in time to network
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I have this log file which is recording the log in/ log out sessions by users to the network
[10:21:10] User logged in
[13:59:42] User logged out
[15:42:00] User logged in
[16:42:13] User logged out
[11:15:02] User logged in
[11:42:23] User logged out
I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.
in this example it will be 5:06:06 hours
logs
New contributor
add a comment |Â
up vote
2
down vote
favorite
I have this log file which is recording the log in/ log out sessions by users to the network
[10:21:10] User logged in
[13:59:42] User logged out
[15:42:00] User logged in
[16:42:13] User logged out
[11:15:02] User logged in
[11:42:23] User logged out
I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.
in this example it will be 5:06:06 hours
logs
New contributor
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have this log file which is recording the log in/ log out sessions by users to the network
[10:21:10] User logged in
[13:59:42] User logged out
[15:42:00] User logged in
[16:42:13] User logged out
[11:15:02] User logged in
[11:42:23] User logged out
I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.
in this example it will be 5:06:06 hours
logs
New contributor
I have this log file which is recording the log in/ log out sessions by users to the network
[10:21:10] User logged in
[13:59:42] User logged out
[15:42:00] User logged in
[16:42:13] User logged out
[11:15:02] User logged in
[11:42:23] User logged out
I want to calculate the total time spent on line for all users together, the log file above is actually very long and this is just an example.
in this example it will be 5:06:06 hours
logs
logs
New contributor
New contributor
edited yesterday
New contributor
asked yesterday
Cellman
133
133
New contributor
New contributor
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You can try sed
and awk
for this task:
cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'
5:06:06
sed
will line up "login" and "logout" time frames per user, then awk
will do time calculation for the relevant columns.
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can try sed
and awk
for this task:
cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'
5:06:06
sed
will line up "login" and "logout" time frames per user, then awk
will do time calculation for the relevant columns.
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
add a comment |Â
up vote
1
down vote
accepted
You can try sed
and awk
for this task:
cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'
5:06:06
sed
will line up "login" and "logout" time frames per user, then awk
will do time calculation for the relevant columns.
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can try sed
and awk
for this task:
cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'
5:06:06
sed
will line up "login" and "logout" time frames per user, then awk
will do time calculation for the relevant columns.
You can try sed
and awk
for this task:
cat file | sed -r 'N; s/n/ /; s/] User logged [^ ]+//g; y/[:/ /' | awk 's += ($4-$1)*3600 + ($5-$2)*60 + $6-$3END printf "%d:%02d:%02dn", s/3600, s/60%60, s%60'
5:06:06
sed
will line up "login" and "logout" time frames per user, then awk
will do time calculation for the relevant columns.
answered yesterday
Goro
7,57753371
7,57753371
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
add a comment |Â
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
1
1
This is brilliant!! Thank you very much !
â Cellman
yesterday
This is brilliant!! Thank you very much !
â Cellman
yesterday
add a comment |Â
Cellman is a new contributor. Be nice, and check out our Code of Conduct.
Cellman is a new contributor. Be nice, and check out our Code of Conduct.
Cellman is a new contributor. Be nice, and check out our Code of Conduct.
Cellman is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473801%2fcaclulate-total-log-in-time-to-network%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password