You are not logged in.
Pages: 1
I need to write an application (probably in java) which will run in the background and wait for a user to login. When the users logins it monitor the applications he/she runs and whenever a logoff is detected it stop monitor application usage. In other words I need to know when the user logs in, starts an application, and logoff. So my question is, how is it possible to know this in linux/unix.
Thanks in advance for your time.
Offline
Is there not already logging daemons running that log this activity? Shouldn't this information be in /var/log somewhere?
Offline
Login and logoff times are in /var/log/wtmp which is a binary file. You can browse it with last. See source for last if you need to read /var/log/wtmp yourself instead of executing an external program.
Your application could watch /var/log/wtmp for changes. When a change is detected, see who logged in (or stop monitoring the user that logged off). If you need something quick & dirty, you could just as well write everything in a bash script and use ps at regular intervals to see which processes that user is running.
Offline
Pages: 1