Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
I set the TMOUT variable to be read only in my /etc/profile to make sure all users log out if they are not using the system for 1800 they cannot ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    178

    How to make a env variable user specific


    I set the TMOUT variable to be read only in my /etc/profile to make sure all users log out if they are not using the system for 1800

    they cannot change this in their .profile as it is read only.


    TMOUT=1800
    readonly TMOUT
    export TMOUT


    I want to allow an exception for the oracle application ID not to log out at all.

    I was thinking of some sort of case statement in the /etc/profile might work.

    Any thoughts on this?

    Basically I could have several application related ids that should not logout automatically.

    Any pointers would be appreciated.

  2. #2
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,066
    I thought that /etc/profile only ran for login shells and wouldn't affect applications?

  3. #3
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    178
    This is a login user not just background processes.

  4. #4
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,066
    You can apply logic to the user ids you wish to affect with something like this:
    Code:
    for each in 1000 2000 3000; do 
        if [[ $(/usr/bin/id -u) -eq $each ]]; then  
            <do stuff here>
        fi 
    done
    It can be reversed by testing with "-ne" - the list becomes the ones not to apply the logic too.

  5. #5
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    904
    Just thinking about this (I know thinking is dangerous)

    Service accounts like apache or mysql and imagine oracle don't get logged in so nothing to logout, right???

    Also why not have whatever script you're using to check users, why not just build the list to check at runtime. The who and w commands can give you list of logged on users. If you look at the man pages for those commands you can get a nice list.

    Just thinking out loud.

  6. #6
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,066
    Quote Originally Posted by docbop View Post
    Just thinking about this (I know thinking is dangerous)

    Service accounts like apache or mysql and imagine oracle don't get logged in so nothing to logout, right???
    Yes, /etc/profile only affects login shells AFAIK. If some of the applications opened a login shell under a specific user it would affect them though. Some of the remote tools might.

  7. #7
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    178
    Well oracle does login and do installs and db maint not just run in the background.

  8. #8
    Linux Engineer
    Join Date
    Dec 2013
    Posts
    1,066
    Remote logins done through ssh do run a login shell - shell scripts run remotely will be associated with a user id. On the other hand connections through sqlplus, call interface, odbc don't.

  9. #9
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    178
    Quote Originally Posted by gregm View Post
    You can apply logic to the user ids you wish to affect with something like this:
    Code:
    for each in 1000 2000 3000; do 
        if [[ $(/usr/bin/id -u) -eq $each ]]; then  
            <do stuff here>
        fi 
    done
    It can be reversed by testing with "-ne" - the list becomes the ones not to apply the logic too.
    So this seem to be the answer I was thinking would work.
    I will have to test it but this should do us since there is no way to allow the oracle id to be allowed to use the variable TMOUT in its .profile.

  10. #10
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    178
    So I tried several things here. none return the expected results.

    TMOUT=1800
    readonly TMOUT
    export TMOUT
    for each in 755; do
    if [[ $(/usr/bin/id -u) -eq $each ]]; then
    export TMOUT=
    fi
    done


    and I tried


    for each in 755; do
    TMOUT=1800
    readonly TMOUT
    export TMOUT
    if [[ $(/usr/bin/id -u) -eq $each ]]; then
    export TMOUT=
    fi
    done


    and I tried this code
    for each in 755; do

    if [[ $(/usr/bin/id -u) -eq $each ]]; then
    export TMOUT=
    else
    TMOUT=1800
    readonly TMOUT
    export TMOUT
    fi
    done

    all get this output
    $ echo $TMOUT
    + echo 1800
    1800

    I know I am missing something simple here.
    Last edited by unix1adm; 02-05-2014 at 05:39 PM.

Page 1 of 2 1 2 LastLast

Posting Permissions

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