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

风流意气都作罢 提交于 2019-12-11 18:14:04

问题


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.)


回答1:


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.




回答2:


Since you reference "ssh", I'm gonna guess you are on *nix.

Have a look at cron

Redirecting output in *nix is easy, just use the ">" and "2>" redirections.



来源:https://stackoverflow.com/questions/22250843/run-java-jar-myjar-jar-automatically-on-linux-server-instead-of-on-login-and

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!