LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2009, 10:25 AM   #1
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Rep: Reputation: 18
Question ShellScrtips that run at Different System/User Level Events


Hi All,


I want to run certain ShellScrpts whenever:

a user logs in, be it from Graphical Interface that is X, or from Virtual Console;

a user logs out;

a user restarts system;

a user shuts down system.


I am using Red Hat Enterprise Linux 5 and GNOME Desktop Environment.

Wherein can I make such configurations?


Thanks in advance!

Dev.
 
Old 05-14-2009, 11:13 AM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Look in /etc/rc.d/rc<run_level>.d/ and /etc/init.d/, paying close attention to /etc/rc.d/rc.local

Generally, scripts (usually in /etc/init.d) symlinked from /etc/rc.d/rc<run_level>.d with namse starting with K are executed when the system boots to that run level, and, if they start with an S, the script is called when therun level is exited. The rc.local script is run at the end of the boot process. For users, there is .bashrc to be executed when bash is started, and the Autorun directories in various .<Display_Manager> directories which are run when the user logs in to a specific display manager.
 
Old 05-14-2009, 08:11 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,411

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Those will work for restart/shutdown.
For login you could look at /etc/profile.
For logout I'm not sure; there's .bash_logout, but that's for each shell instance.
You could look at this: http://linux.derkeiler.com/Mailing-L...-08/2313.html; a solution for KDE, might be an equiv for Gnome as well.
 
Old 05-15-2009, 07:53 AM   #4
Hi_This_is_Dev
Member
 
Registered: May 2009
Location: India
Distribution: On my PC I use RHEL, at office AIX, Solaris, HP-UX, RHEL.
Posts: 254

Original Poster
Rep: Reputation: 18
Lightbulb

I have already tired /etc/profile and it really serves the purpose of running a script when any user logs in.

It eliminates the time-consuming task of modifies each user's .bash_profile file.

Well, now let's take: .bash_logout file. I can make use of it in a similar fashion but again I have to modify each user's .bash_logout file.

Is there any way to do it on a "system-wide" level?

Quote:
Originally Posted by chrism01 View Post
Those will work for restart/shutdown.
For login you could look at /etc/profile.
For logout I'm not sure; there's .bash_logout, but that's for each shell instance.
You could look at this: http://linux.derkeiler.com/Mailing-L...-08/2313.html; a solution for KDE, might be an equiv for Gnome as well.
 
  


Reply

Tags
events, system


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
emacs in run level 3 then switch to X (level 7) then back to level 3 dsoliver Slackware 3 09-01-2006 04:31 AM
System hangs on Boot-up at Run level 3 ayush Linux - Newbie 7 12-16-2005 09:41 AM
System hangs on Boot-up at Run level 3 ayush Red Hat 2 12-07-2005 01:26 PM
System hangs on Boot-up at Run level 3 ayush Linux - General 1 12-06-2005 11:19 AM
System hangs on Boot-up at Run level 3 ayush Linux - Enterprise 0 12-06-2005 11:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration