How to run script on logout ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run script on logout ?
# 1  
Old 02-19-2010
Bug How to run script on logout ?

Hi Everybody,
I want to run my own script on logout , i can use .bash_logout file... problem is this will work only for that particular user... i want to know the common file... so that script wil run for all the user...

2. How to run script on Shutdown ?

Thanks in advance

Anitha
# 2  
Old 02-19-2010
Checkout /etc/bash.bash_logout for logout. What should work of course is using links in /etc/rc.d for the appropriate runlevel 0 and 6 with a K in their name, pointing to a stop script.

Checkout these two links:
Runlevel - Wikipedia, the free encyclopedia
Chapter*7.*The rc.d System

Last edited by zaxxon; 02-19-2010 at 01:43 AM.. Reason: updated and corrected info
# 3  
Old 02-19-2010
Thanks for ur reply ...

but no such file is available in /etc directory .... can u tel any other way... to do ths...
# 4  
Old 02-19-2010
Just create this file then and try it out. Also telling which OS you use might help.
# 5  
Old 02-19-2010
There are several command to do that
Code:
 
/sbin/shutdown
/sbin/poweroff
/sbin/halt

But you must be a super user to do this, As a normal user you can do only a logout operation , for that you can provide kill -9 -1 , Sending a kill signal to all the process.

Last edited by abubacker; 02-19-2010 at 06:18 AM.. Reason: change the line from [\code] to [/code]
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Logout automatically when exiting a script

Hi, I am using SCO Unix. I write a script to execute a program by calling exec program The script will check the program is still there or not, if not, then it will exit the script by calling exit So if I press DEL to quit the program, the script will exit, but it will logout... (6 Replies)
Discussion started by: dannychan
6 Replies

2. Shell Programming and Scripting

shell script to run after ssh logout from another machine

Scenario: I currently manager a cluster at work which is on a private network and i constantly need to ssh to other clients for diags e.t.c. I created a debain client which i use as my gateway to get to all the clients on the private network and I then created a Shell menu script which will make... (4 Replies)
Discussion started by: defamer
4 Replies

3. Shell Programming and Scripting

Logout script - delete a file

Good evening you scripting guru's! I have the following script to delete a file on logout of a Mac : find . –name com.apple.sidebarlists.plist –exec rm -f {} \; It works fine in terminal and when logging out. However, it takes forever to run the script at logout...A minute and a half. ... (12 Replies)
Discussion started by: AGGreenLinux
12 Replies

4. OS X (Apple)

Login/Logout script

Dear readers I use SnowLeopard 10.6.2 and need to do some special tasks at login and logout of an sepcific user. My problem is, how do I send a string "login" respectively "logout" from computer "A", where the login/logout script runs, to computer "B" where some other tasks need to be done. ... (3 Replies)
Discussion started by: tthaler
3 Replies

5. UNIX for Advanced & Expert Users

logout script common for both Mac and Linux?

hi all , I need to run few commands on user logout. A non-root user should be able to edit that script which runs after logout. I need to make the solution both all Linux versions as well as Mac. Can any body help me in this regard. (0 Replies)
Discussion started by: harsha10
0 Replies

6. UNIX for Dummies Questions & Answers

run a script at logout

hi all , Need to a run a program on user logout (using GNOME log screen). Tried using .bash_logout for this purpose but that doesnt seem to work. Similar to .bash_logout is there any script /program which a normal user (other than root ) can edit and run it on their logout? can anybody... (0 Replies)
Discussion started by: harsha10
0 Replies

7. Shell Programming and Scripting

run a script on logout by a non-root user

hi , i need to run a script that delete files when i logout as a user other than root user . I have tried out using .bash_logout but that doesnt seem to work , so any alternative for this to be done. Thanks in advance, Harsha (6 Replies)
Discussion started by: harsha10
6 Replies

8. Shell Programming and Scripting

set schedule to run a script at background while logout

Hi, How can I run a script at 9:00am and 6:00pm everyday? Can I run it at background while I logout my account? Please help!! Many Thanks!! (1 Reply)
Discussion started by: happyv
1 Replies

9. UNIX for Dummies Questions & Answers

Login and logout script

Hi all I know ho I can run a script when a user logs in, viz using the .login or .profile file, however what can I use to run a script when a user logouts ? Thanks J :confused: (1 Reply)
Discussion started by: jhansrod
1 Replies

10. UNIX for Dummies Questions & Answers

logout/shutdown script

I am running JDictd (http://www.informatik.uni-leipzig.de/~duc/Java/JDictd/) from tcsh in Terminal on Mac OS X (:=Darwin=FreeBSD/Mach). I am trying to get it to exit cleanly silently upon Mac OS X system shutdown. My idea was that if there was a logout script in FreeBSD (basically a script... (1 Reply)
Discussion started by: ropers
1 Replies
Login or Register to Ask a Question