Sponsored Content
Operating Systems Linux Red Hat How do you logout from a session? Post 67685 by Heron on Friday 25th of March 2005 09:05:22 AM
Old 03-25-2005
Quote:
Originally Posted by zazzybob
If I understand you correctly, an easier solution would be to have something like this in .bash_profile directly

Code:
cd $HOME/applications
./move_some_files
# make sure the exec is the last line
exec ./start_application

bash itself will then be replaced by ./start_application - therefore when ./start_application terminates, you'll be logged out and returned to the prompt.

Cheers
ZB

Thanks for the responses!

I've tried using logout in my script, but it doesn't do anything. I've tried using exit and that doesn't work either.

I've also tried starting the app within .bash_profile - as the last line and that won't work either!

I was able to kill the session by doing this within my script:

declare -r PIDNUM=`ps -ef | grep gnome-session`
kill -9 `echo $PIDNUM | cut -d' ' -f2`

Here's the kicker:

This will work and kill the session thus logging the user out and returning them to the login screen, but only if you're already logged in and run this from the command line.

However

This doesn't work if the user logs in from the log in screen. The script does indeed take place - files are moved, the application is started, and files are replaced. But, it doesn't end the session - the normal log in procedure takes place i.e. the desktop is setup etc...

I'm at a loss here.

Thanks.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies

2. Shell Programming and Scripting

Hiding Directories on a Session by Session basis

Hi, Apologies if anyone has read my recent post on the same subject in the Linux forum, just thought actually the solution might more likely come from scripting. Essentially, I am trying to restrict access to directories based on the user's name AND their location on a session-by-session... (3 Replies)
Discussion started by: en7smb
3 Replies

3. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

4. Shell Programming and Scripting

session logout

hi, im executing one script i,e sh test.sh i want to log out the sessing after script execution. and i do't want to user command like this. sh test.sh ; exit can i exit the session with the use of script pl help (1 Reply)
Discussion started by: arvindng
1 Replies

5. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

6. Shell Programming and Scripting

Determining if session is a login session

Besides 'who am i' and 'tty' what commands could be used to determine if a session is interactive as compared to a web process or cron process. Any command should work with the common unix variants. (3 Replies)
Discussion started by: jgt
3 Replies

7. Solaris

Difference between the desktop session and console session

what is the difference between desktop session and console session in solaris as i am wondering we use option -text for the former and -nowin for the later (1 Reply)
Discussion started by: kishanreddy
1 Replies

8. UNIX for Dummies Questions & Answers

Session logout

hi, i want to make a session logout in c++/unix which will redirect the user to the login page if the user is idle for 5mins (1 Reply)
Discussion started by: anubhav sharma
1 Replies

9. UNIX for Advanced & Expert Users

Login and logout time of a session

Hi, How can I find out the login and logout time of the old UNIX session/user?. (2 Replies)
Discussion started by: sharif
2 Replies
PAM_SYSTEMD(8)							    pam_systemd 						    PAM_SYSTEMD(8)

NAME
pam_systemd - Register user sessions in the systemd control group hierarchy SYNOPSIS
pam_systemd.so DESCRIPTION
pam_systemd registers user sessions in the systemd control group hierarchy. On login, this module ensures the following: 1. If it does not exist yet, the user runtime directory /run/user/$USER is created and its ownership changed to the user that is logging in. 2. The $XDG_SESSION_ID environment variable is initialized. If auditing is available and pam_loginuid.so run before this module (which is highly recommended), the variable is initialized from the auditing session id (/proc/self/sessionid). Otherwise an independent session counter is used. 3. A new control group /user/$USER/$XDG_SESSION_ID is created and the login process moved into it. On logout, this module ensures the following: 1. If $XDG_SESSION_ID is set and kill-session-processes=1 specified, all remaining processes in the /user/$USER/$XDG_SESSION_ID control group are killed and the control group is removed. 2. If last subgroup of the /user/$USER control group was removed the $XDG_RUNTIME_DIR directory and all its contents are removed, too. If the system was not booted up with systemd as init system, this module does nothing and immediately returns PAM_SUCCESS. OPTIONS
The following options are understood: kill-session-processes= Takes a boolean argument. If true, all processes created by the user during his session and from his session will be terminated when he logs out from his session. kill-only-users= Takes a comma separated list of user names or numeric user ids as argument. If this option is used the effect of the kill-session-processes= options will apply only to the listed users. If this option is not used the option applies to all local users. Note that kill-exclude-users= takes precedence over this list and is hence subtracted from the list specified here. kill-exclude-users= Takes a comma separated list of user names or numeric user ids as argument. Users listed in this argument will not be subject to the effect of kill-session-processes=. Note that that this option takes precedence over kill-only-users=, and hence whatever is listed for kill-exclude-users= is guaranteed to never be killed by this PAM module, independent of any other configuration setting. controllers= Takes a comma separated list of control group controllers in which hierarchies a user/session control group will be created by default for each user logging in, in addition to the control group in the named 'name=systemd' hierarchy. If omitted, defaults to an empty list. reset-controllers= Takes a comma separated list of control group controllers in which hierarchies the logged in processes will be reset to the root control group. debug= Takes a boolean argument. If yes, the module will log debugging information as it operates. Note that setting kill-session-processes=1 will break tools like screen(1). Note that kill-session-processes=1 is a stricter version of KillUserProcesses=1 which may be configured system-wide in systemd- logind.conf(5). The former kills processes of a session as soon as it ends, the latter kills processes as soon as the last session of the user ends. If the options are omitted they default to kill-session-processes=0, kill-only-users=, kill-exclude-users=, controllers=, reset-controllers=, debug=no. MODULE TYPES PROVIDED
Only session is provided. ENVIRONMENT
The following environment variables are set for the processes of the user's session: $XDG_SESSION_ID A session identifier, suitable to be used in file names. The string itself should be considered opaque, although often it is just the audit session ID as reported by /proc/self/sessionid. Each ID will be assigned only once during machine uptime. It may hence be used to uniquely label files or other resources of this session. $XDG_RUNTIME_DIR Path to a user-private user-writable directory that is bound to the user login time on the machine. It is automatically created the first time a user logs in and removed on his final logout. If a user logs in twice at the same time, both sessions will see the same $XDG_RUNTIME_DIR and the same contents. If a user logs in once, then logs out again, and logs in again, the directory contents will have been lost in between, but applications should not rely on this behaviour and must be able to deal with stale files. To store session-private data in this directory the user should include the value of $XDG_SESSION_ID in the filename. This directory shall be used for runtime file system objects such as AF_UNIX sockets, FIFOs, PID files and similar. It is guaranteed that this directory is local and offers the greatest possible file system feature set the operating system provides. EXAMPLE
#%PAM-1.0 auth required pam_unix.so auth required pam_nologin.so account required pam_unix.so password required pam_unix.so session required pam_unix.so session required pam_loginuid.so session required pam_systemd.so kill-session-processes=1 SEE ALSO
pam.conf(5), pam.d(5), pam(8), pam_loginuid(8), systemd-logind.conf(5), systemd(1) AUTHOR
Lennart Poettering <lennart@poettering.net> Developer systemd 10/07/2013 PAM_SYSTEMD(8)
All times are GMT -4. The time now is 02:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy