-1

I have a development env. with 4 users, I want to be able to log their time logged in since they are contractor working from home.

I have NO idea how to do it, my sys admin left me this weekend and I am lost here. I want to be able to run a script or a command for the first login only, per day. and if possible when they log out.

example:

today @ 8am user1 log in: execute a command /path/command.sh today @ 9am user2 log in: execute a command /path/command.sh today @ 2pm user1 logout today @ 3pm user1 login: do nothing today @ 4pm user1 login (second shell window): do nothing etc...

I think I can use the .profile file but i am not sure thanks

running on ubuntu server 12.04

  • What is your end goal, to simply track what time they first logged in? Or to actually perform some action at that exact point in time? – John Dec 4 '13 at 13:05
  • What if they log in but do nothing the whole day ? – Vinz Dec 4 '13 at 13:08
  • @John both, I would like to track their time and execute a command, the sys admin created a script that tracked the time and send it to a server which i only have access – Pat R Ellery Dec 4 '13 at 13:09
  • @Vinz oh I didnt think about that ... is it possible to track if there's no activity? – Pat R Ellery Dec 4 '13 at 13:10
  • It would have been helpful to know what operating system this relates to. This kind of auditing is standard on most versions of Linux/Unix/BSD (see 'last' command) – symcbean Dec 4 '13 at 13:21
2

To track the time they log in, you don't need to do anything. The last command will tell you when they logged in, even a week and a half later. IT will also tell you when they logged out, which you may find useful.

As far as running a command, you can use the .profile file, but the biggest issue with that is many programmers will modify this file to set up the environment they prefer, potentially wiping out your changes. Please, don't tell them they can't do that - setting up an individual environment through dot-files is just part of the job. You'd look technically inexperienced at best, we won't go into the worst part.

Honestly, what I would recommend is finding another way to do whatever it is your doing by executing that command. That's a personnel / sociological / management issue, and trying to solve those issues via technical means is... not good. And, as @Vinz points out, just logging when they log in doesn't mean you're getting useful information about the work they're doing.

  • 1
    Agreed - a better way to track their time is to manage the project(s) and hold people to deliverables and timetables. If you don't trust your contractors, you've got a lot of non-technical work to do. – mfinni Dec 4 '13 at 13:26
0

There a couple of easy commands you can use to see what they are currently doing.

  • lastlog #see when the last logged on
  • who #see who currently is connected to the machine
  • ps -U username #shows which processes they are using
  • lsof | grep username #shows what fiels they have in use

but this seems more like a management issue or maybe even a trust issue?

  • an alternative is that if u really wanted to anyway is in the /etc/bashrc something like this if [[ -n $SSH_CONNECTION ]] ; then echo "I'm logged in remotely" fi – Koen van der Rijt Dec 4 '13 at 13:40
  • You're not guaranteed to have /etc/bashrc executed at user login. It's called by the user's dotfiles, and if it were me logging in and I saw this in /etc/bashrc, I'd simply copy the contents to my .bashrc without that log command, not execute /etc/bashrc, and go on with life. – John Dec 4 '13 at 13:49
  • agreed... its easily circumvented. Should have mentioned it.. – Koen van der Rijt Dec 4 '13 at 14:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.