LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
Search this Thread
Old 07-29-2009, 06:43 PM   #1
rammohan04
LQ Newbie
 
Registered: Jul 2009
Posts: 1

Rep: Reputation: 0
in bash shell how to run shell script during startup


in bash shell how to run shell script during startup
 
Old 07-29-2009, 10:28 PM   #2
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by rammohan04 View Post
in bash shell how to run shell script during startup
If you want it executed for every instance of a shell that you start, call it from ~/.bashrc. If you want it executed only once per login, call it from ~/.bash_profile or ~/.profile.

From the man page:
Code:
       When  bash  is  invoked as an interactive login shell, or as a
       non-interactive shell with the --login option, it first reads
       and executes commands from the file /etc/profile, if that file
       exists.   After reading  that  file,  it looks for /.bash_profile,
       ~/.bash_login, and ~/.profile, in that order, and reads and
       executes commands from the first one that exists and is readable.
       The  --noprofile  option may be used when the shell is started to
       inhibit this behavior.

       When an interactive shell that is not a login shell is started,
       bash reads and executes commands from ~/.bashrc, if that file
       exists.  This may be inhibited by using the --norc option.  The
       --rcfile file option will force bash to read and execute commands
       from file instead of ~/.bashrc.
 
Old 07-31-2009, 02:07 AM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
If its only once at system boot, usually put it in /etc/rc.local, although it can vary depending on distro.
Please add your distribution name & version to your profile.
 
  


Reply


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
Restrict a Shell Script to run from a shell bharaniks Linux - Security 7 08-26-2007 10:57 PM
bash shell startup files mariogarcia Linux From Scratch 2 08-14-2007 04:00 AM
run shell script bash from browser with php achilles Programming 10 08-02-2007 03:44 PM
Run a C Shell using only Bash shell HSN Linux - Software 1 12-25-2006 07:44 AM
Bash Shell Startup Files - Not working! Carl-Fredrik Linux From Scratch 1 10-20-2004 03:52 PM


All times are GMT -5. The time now is 09:28 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration