0

I have a spring boot application which, in order to run succussfully, a specific config file must be in the current directory(the PWD where I run the java -jar command in the terminal). (I let my code find the config file in ./, I now know that it is a bad idea). Each time I run the app, I have to firstly cd to the directory where the config file residents, then run the java -jar command.

Problem is that I have to make my application auto run after the ubuntu system boots, but I failed to achieve that in a whole day. I tried to put the java -jar command in /etc/rc.local, but the application never run after the system boot. Also I tried to add the cd command before it, but does not work either.

Is there any suggestions?

the rc.local :

#!/bin/sh
#
#This script will be executed *after* all the other init scripts.
#You can put your own initialization stuff in here if you don't
#want to do the full Sys V style init stuff.

/bin/bash /root/geiri-cmd.sh start defcns

cd /home/geiri1012
/home/geiri1012/jdk/bin/java -jar /home/geiri1012/httpInterface.jar

exit 0
8
  • 1
    Which Ubuntu version? rc.local may not be enabled (I think it is not on new installations).
    – vanadium
    Oct 13, 2020 at 13:47
  • 16.04 , it should have been enabled, since another python application can auto run after it is configed in rc.local @vanadium
    – ZhaoGang
    Oct 13, 2020 at 13:49
  • It will be a good idea to post your current rc.local file then. Anything can be wrong, and currently we can only guess. Also rephrase your question: apparently it is not only about cd.
    – vanadium
    Oct 13, 2020 at 13:51
  • @vanadium I updated my post.
    – ZhaoGang
    Oct 13, 2020 at 14:03
  • Looks good, with absolute paths throughout. A cd /home/user/jdk/bin/java should change the working directory successfully.
    – vanadium
    Oct 13, 2020 at 14:07

0

You must log in to answer this question.

Browse other questions tagged .