Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to run Solr on startup or automatically on a VPS with CentOS 6.0, and I have read the answers in Stack Overflow question How to start Solr automatically?.

And I could not execute this to the required solution.

At first, I created a .sh file with a cron job, and it's not working. I also tried the other answers too, but I could not figure out why shell script doesn't run.

And I even tried executing it directly by the below commands.


But I got an error that 1. Cannot find the directory 2. Cannot execute the Java file and script code below


cd /opt/solr/example/solr/example
java -jar start.jar

Note: /opt/solr/example is my Solr home directory.

Is there a way to create a cron or automated job or a file that can run on startup?

share|improve this question

migrated from Dec 24 '12 at 22:20

This question came from our site for professional and enthusiast programmers.

Is that the entire contents of your shell script? – fbynite Dec 24 '12 at 7:28
yes, except the Note – Rafee Dec 24 '12 at 7:33
Does the directory in your shell script actually exist? – fbynite Dec 24 '12 at 7:44
Yes. I can execute each every command mentioned above.. – Rafee Dec 24 '12 at 7:48
Okay, It just got executed, now how to place in startup, i tried to place in /etc/init.d/ – Rafee Dec 24 '12 at 7:48
up vote 1 down vote accepted

You can also start your script up from /etc/rc.local.

First make sure the directory in your shell scripts exists and that it runs without errors. If it does, be sure to make it executable by running the command chmod a+x script_name.

Move your shell script under the directory /etc/init.d/. Add the following line /etc/init.d/script_name to /etc/rc.local. Reboot, check that your service has started.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.