LinuxQuestions.org
Visit Jeremy's Blog.
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 11-25-2010, 03:16 AM   #1
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Rep: Reputation: Disabled
bash script not running on centos


Hi all,
I am a newbie in linux.
I tried to write an autorun bash script on /root and select System-Preferences-More Preferences-Sessions-Startup Programs-Add.
But the bash script seems like not working.
Following is my bash script:

#!/bin/bash
#
#chkconfig:345 99 99
#Description:Script to change /dev/random
/opt/apache-tomcat/bin/./startup.sh
/etc/init.d/httpd start
/etc/init.d/mysqld start

Anythg wrong wth my bash script? Or is there any setting that I can make so that I can auto-run my tomcat,httpd andf mysqld?

Please guide me. Looking forward to hear from you.

Thanks in advance,
Allen Wilson
 
Old 11-25-2010, 03:31 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
Hi. First check permissions and see if the file is executable. I don't know about the tomcat startup script, but for services like httpd and mysqld you can activate them to be started at boot. Go to System --> Administration --> Services and check the box near them.

An aside note: please take in mind that is not a good idea running the X environment as root, since it can make the system more vulnerable to potential attacks.
 
Old 11-25-2010, 03:32 AM   #3
T0sh1r0
Member
 
Registered: Oct 2010
Location: Liège, Belgium
Distribution: Debian / Slackware
Posts: 47
Blog Entries: 1

Rep: Reputation: 7
Hello,

Which user owns the script? Root I guess as the script is in /root.
And with which user are you running it?
Have you given execute permission to the user running the script?
Did you got an error message? If no, try to run the script from the command line and copy/paste the error message here.
 
Old 11-26-2010, 03:09 AM   #4
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi..
I try to run the script from the command line and follwoing are the results:
[root@localhost ~]# ./autorun.sh
Using CATALINA_BASE: /opt/apache-tomcat
Using CATALINA_HOME: /opt/apache-tomcat
Using CATALINA_TMPDIR: /opt/apache-tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_21
Using CLASSPATH: /opt/apache-tomcat/bin/bootstrap.jar
Starting httpd:
Starting MySQL: [ OK ]

How to grant permision to the bash script? This script belongsto the root user, and root user going to run it.

Please guide me. Thanks in advance!
 
Old 11-26-2010, 07:57 AM   #5
T0sh1r0
Member
 
Registered: Oct 2010
Location: Liège, Belgium
Distribution: Debian / Slackware
Posts: 47
Blog Entries: 1

Rep: Reputation: 7
As root, you should only give execute permissions to your script:
Quote:
chmod +x autorun.sh
In case you want all users on your system to be able to run (and read) your script then do
Quote:
chmod 755 autorun.sh
You should have a look a the documentation of chmod as this is a common command ;-)
 
Old 11-26-2010, 08:09 AM   #6
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

Rep: Reputation: 30
Quote:
Starting httpd:
Starting MySQL: [ OK ]
httpd service was already started so there was no "[ OK ]" message next to it.
mysql service was not running and it was started successfully.

---------------------------------------------

Hmm I think you want to start httpd, mysql and tomcat every time the server boots up.

There is another simple solution to make httpd and mysql start up automatically:

Quote:
# chkconfig httpd on
# chkconfig mysql on
--- to verify if they will start on various runlevels:
Quote:
# chkconfig --list httpd
# chkconfig --list mysql
as for tomcat... you might want to add (append at the bottom) the following line (which I got from your script) to "/etc/rc.local":
Quote:
/opt/apache-tomcat/bin/./startup.sh

Last edited by chickenjoy; 11-26-2010 at 08:17 AM.
 
Old 11-26-2010, 08:09 AM   #7
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

Rep: Reputation: 30
double post.

Last edited by chickenjoy; 11-26-2010 at 08:10 AM.
 
Old 11-28-2010, 08:21 PM   #8
allensim81
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: Disabled
Hi, For httpd and mysqld, it can auton run now! But for apache, teh autorun doesnt work!

How to add (append at the bottom) /opt/apache-tomcat/bin/./startup.sh to "/etc/rc.local" ?

Please guide me. I wonder what happened to my apache tomcat, it still cannot autorun after restart/reboot.


Please help.
Thanks in advance,
Allen Wilson
 
  


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
[SOLVED] How to make a bash script keep running in same terminal after it calls second script? JohnRock Linux - Newbie 4 06-25-2010 09:16 AM
Running Bash script in PHP script SteveMack2015 Linux - Software 2 05-14-2010 03:34 PM
[SOLVED] Running a bash script via ssh jhameier Linux - Newbie 4 04-09-2010 06:35 AM
Running a bash script at startup linker3000 Linux - Software 2 05-17-2007 10:00 PM
running su from a bash script caminoix Programming 7 12-28-2005 03:41 PM


All times are GMT -5. The time now is 01:17 AM.

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