0

I used to run this script in Startup and Session in Xubuntu 14.04 to autostart my java app:

xfce4-terminal -e "bash -c \"cd /home/restaurant/Documents/dist/ && java -jar POSv2.jar; exec bash\""

but running the same script in 16.04 causes MySQL Exceptions; I assume these exceptions were thrown because MySql wasn't loaded yet when the script ran. Therefore my question to you how can I make sure the script only get called once MySQl has been loaded successfully?

Chiggiddi
  • 345

1 Answers1

0

Create a script that start every boot that checking every 2 seconds if MySql process is running, if so execute your command.

Lets create the script called filename.sh with this content:

#!/bin/bash
APP="gedit"
while true; do    
    PID=`pidof $APP`
    if [ ! -z $PID ]; then
        # We found the process running on the system.            
        java -jar "/home/restaurant/Documents/dist/POSv2.jar"
        exit 0
    fi
    sleep 2
done

make it executable:

chmod +x filename.sh

Just change APP="gedit" to the process name instead of gedit.
Make it running at the start up: How do I run a script at start up?.

Benny
  • 4,920
  • Hi Benny, thanks a lot for your input. I will try to implement and test the solution you are proposing. I will give a feedback afterwards. – Chiggiddi Nov 09 '16 at 04:48