Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

java.io.FileNotFoundException: 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.

Thanks

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

1 Answer 1

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

 
discard

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.