LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   in bash shell how to run shell script during startup (http://www.linuxquestions.org/questions/red-hat-31/in-bash-shell-how-to-run-shell-script-during-startup-743789/)

rammohan04 07-29-2009 06:43 PM

in bash shell how to run shell script during startup
 
in bash shell how to run shell script during startup

David1357 07-29-2009 10:28 PM

Quote:

Originally Posted by rammohan04 (Post 3624838)
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.


chrism01 07-31-2009 02:07 AM

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.


All times are GMT -5. The time now is 05:36 PM.