users login

Hello everyone

I need to send to a file the last command from all users who log in and log out by week or month.

My questions are

I can do it with the command or I need to do a script ?

If the answer is I need to do a script, someone can help me because Im complete new to make a script.

I know that I can send the last command to a file.

last >testlogin.txt

but I need to do this more specific by week or month, by user maybe

Thanks for your tips

Greetings

Looking at the last command, and it output, what do you mean by user's last command? It shows user, connection, day, date, time, and possibly if still connected.

A script could be written to extract from this file, but do not understand what you are trying to find. Can you supply more info and perhaps a sample of what you are trying to create?

A command like:

last | tr -s " " | cut -d" " -f1,5 | sort -u

would show users and months they had access/activity in.

Thanks for your reply joeyg

If I type the last command and to a text file. I get this

last >usuarios.txt
root pts/0 160.40.35.277 May 22 11:08 still logged in.
root pts/0 alopez02 May 22 09:23 - 10:11 (00:47)
root pts/0 160.40.35.277 May 20 13:07 - 13:29 (00:21)
root pts/1 alopez02 May 19 13:19 - 13:35 (2+00:15)

I need to do the same thing but by user, by week or month

Thanks again

Greetings

Hello everyone

I update my question.

Thanks for your reply joeyg

If I type the last command and send to a text file. I get this

last >usuarios.txt
root pts/0 160.40.35.277 May 22 11:08 still logged in.
root pts/0 alopez02 May 22 09:23 - 10:11 (00:47)
root pts/0 160.40.35.277 May 20 13:07 - 13:29 (00:21)
root pts/1 alopez02 May 19 13:19 - 13:35 (2+00:15)

I need to do the same thing but order by week and user.

Another question how I can send the txt file to another computer by ftp

Thanks again

Greetings