Search code examples
javalinuxshelltty

Run "java -jar MyJar.jar" automatically on linux server, instead of on login and run from ssh


How can I run a Java .jar file, fx "java -jar MyJar.jar" automatically on a Linux server, instead every time I login and run it from ssh?

I am looking for some way to automatically execute that command, or something to that effect.

Also, how can I direct all output to some logfile? (I guess stdio in autostrt is unavailable.)


Solution

  • You can use the terminal hooks, like See this answers about the bashrc. When you make a login or open a new terminal on your server, the script will run and execute your script.