-1

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

Dino
  • 47
  • 1
  • 3
  • 5

1 Answers1

0

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"
user9517
  • 115,471
  • 20
  • 215
  • 297