Logon/Logoff script

I need help for writing a logon/logoff script for recording user's computer usage time. This is for local login only, not for ssh or something like that.

When a user logon, there should be a temp file (/home/acct/login_temp) generated including the logname and logon time information in the format like "LogName LogonTime".

When a user logoff, combine temp file and logoff time (in the format of "LogName LogonTime LogffTime"), and append the line to the file /home/acct/Log.txt".

The time format should be hh:mm:ss MM/DD/YY. and the logname should take 10 character (add space if needed).

I guess this is quite a simple job to most of your guys. Hope I can get help here.

Thanks in advance.

Hint: One approach is to write a wrapper program around your login shell (which is called from the /etc/passwd file).

Give it a try and post your results/attempts at writing this wrapper.

I am windows guy and very new to linux and linux script. I don't understand you answer at all. I need more specific help. Thanks.

Sounds to me that, based on your location, you are a student at Iowa State University.

Did you read our forum rules on how to post homework?

Yes, you are right, my IP tells you that I am from Iowa State. But what make you think I am a student? Your act is really not that professional.

Your domain ends in .edu.

Is it not a bit of a giveaway?

I can not believe people at this forum think that the .edu is for student only. Speechless.

You can read the entire Wikipedia article yourself, but here's an extract:

If you have a question, we'd be more than happy to help you answer it. But you have to have done three things first.

The first is to drop the attitude; Secondly post in the suggested forum; Finally make an effort to show what you have tried to this point.

We don't think that .edu is only for students.

However, I am pretty sure you are a student posting homework. You certainly act like one if you are not.