Find the answer to your Linux question:
Results 1 to 2 of 2
I need to know how / where to put a script that executes only for 1 username (actone) at login. I have the script already done. AND: How can I ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    15

    Startup script ONLY for 1 user

    I need to know how / where to put a script that executes only for 1 username (actone) at login.

    I have the script already done.

    AND:
    How can I set a timeout for just this one user? So after they are connected for 2 minutes they get kicked off.

    Lastly:
    At the end of a script how can I force an exit so the user is exited from the session?

  2. #2
    Just Joined! barriehie's Avatar
    Join Date
    Apr 2008
    Posts
    81
    Quote Originally Posted by mackman View Post
    I need to know how / where to put a script that executes only for 1 username (actone) at login.

    I have the script already done.

    AND:
    How can I set a timeout for just this one user? So after they are connected for 2 minutes they get kicked off.

    Lastly:
    At the end of a script how can I force an exit so the user is exited from the session?
    Could put it at the end of his/her .bashrc file and with a timer run:
    Code:
    pkill -KILL -u actone
    Here's a timer script I use to kill other scripts, might have to edit it a bit.
    Code:
    #!/bin/bash
    #
    # Timer script to kill a running process.
    # Usage: timer.sh minutes process_name
    #
    
    if [[ ! $1 || ! $2 ]]; then
        echo "Usage: timer.sh minutes process_name"
        exit 1
    fi
    
    declare -i SEC=$1*60
    declare -i STARTTIME=$(date +%s)
    declare -i STOPTIME=$STARTTIME+$SEC
    declare -i DIFFTIME=$STOPTIME-$STARTTIME
    
    while [ $DIFFTIME -gt 0 ]
    do
        DIFFTIME=$DIFFTIME-1
        sleep 1
    done
    
    killall -s 9 $2
    exit 0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...