Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

This is an extension of my previous post. Basically I want to start the following service automatically when the server is booted:

cd /usr/local/stapi java –jar StApi.jar

this is from Securetrading (payment gateway provider). Basically in a previous post someone suggested running it by:

su - username -c "java -jar /usr/local/stapi/StApi.jar"

but this would not work because their is an ini configuration file in the same directory as the jar file and the above command issued the following error: stapi.ini (No such file or directory)

Please can anyone help with this also I may need to kill the service (not disable it from startup but just stop it) so please can someone advise of the command to stop it as well.


share|improve this question
So then chdir in that directory first. – mailq Dec 10 '11 at 0:11
up vote 0 down vote accepted

You can separate multiple commands with a ;

su - username -c "cd /usr/local/stapi; java -jar /usr/local/stapi/StApi.jar"

or you can use && which will only run the next command if the last completed successfully

su - username -c "cd /usr/local/stapi && java -jar /usr/local/stapi/StApi.jar"
share|improve this answer
Thanks for the help! – Dino Dec 12 '11 at 10:48

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.