Run “java -jar MyJar.jar” automatically on linux s

2019-09-05 23:03发布

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

2条回答
对你真心纯属浪费
2楼-- · 2019-09-05 23:20

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.

查看更多
\"骚年 ilove
3楼-- · 2019-09-05 23:41

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.

查看更多
登录 后发表回答