views:

81

answers:

2

Hi,

I am pretty much new to linux programming. I want to create a log file with some info when a user just logs in. so where can I find an event or something when a user logs in? is there any structure that has some flag when user logs in?

Thanks

A: 

The utmp and wtmp files contain last login data. See the man page for more information.

AKX
kartik
I suppose it could watch the utmp/wtmp files' modification times every second or two or so, and act accordingly.
AKX
Cool.. will try it out!
kartik
A: 

Read the manual page for utmp(5) and getutent(3)

The files:

   /var/run/utmp
   /var/log/wtmp

contain information about who's currently using the system. The wtmp file records all logins and logouts and the utmp file contains information of what kind of login it is, who logged in etc.

Puppe