-1

I need to make a script that checks if a java jar is running on a particular port or not.If the jar is not running then the script should run it automatically.

let's say I want to check if my jar xyz.jar is running on port 3000 or not and if it is not running on port 3000 then the script should free port 3000 and run xyz.jar.

  • Is there any part of this that you know how to do? – G-Man Apr 18 at 6:58
  • well I am a complete noob in bash scripting @G-Man – Nadeem Haider Apr 18 at 6:59
  • @NadeemHaider if pgrep xyz.jar; then echo "Do nothing"; else run_your_script; fi this is for a starter. You can match the port as well using either fuser 3000/tcp or lsof -i :3000 or..? I assume you are running graphana? – Valentin Bajrami Apr 18 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.