linux 常用命令

it2024-04-21  10

Linux 运行jar包命令如下:

方式一:

1 java -jar Sub-Sign- 0.0 . 1 -SNAPSHOT.jar

特点:当前ssh窗口被锁定,可按CTRL + C打断程序运行,或直接关闭窗口,程序退出

那如何让窗口不锁定?

方式二:

1 java -jar Sub-Sign- 0.0 . 1 -SNAPSHOT.jar &

&代表在后台运行。

特定:当前ssh窗口不被锁定,但是当窗口关闭时,程序中止运行。

继续改进,如何让窗口关闭时,程序仍然运行?

方式三:

1 nohup java -jar Sub-Sign- 0.0 . 1 -SNAPSHOT.jar &

nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行

当用 nohup 命令执行作业时,缺省情况下该作业的所有输出被重定向到nohup.out的文件中,除非另外指定了输出文件。

方式四:

1 nohup java -jar Sub-Sign- 0.0 . 1 -SNAPSHOT.jar >temp.txt &

解释下 >temp.txt

command >out.file

command >out.file是将command的输出重定向到out.file文件,即输出内容不打印到屏幕上,而是输出到out.file文件中。

可通过jobs命令查看后台运行任务

1 jobs

那么就会列出所有后台执行的作业,并且每个作业前面都有个编号。如果想将某个作业调回前台控制,只需要 fg + 编号即可。

1 fg  23      

 Linux 查看端口占用情况

  netstat -tunlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 4814/rpcbind tcp 0 0 0.0.0.0:5908 0.0.0.0:* LISTEN 25492/qemu-kvm tcp 0 0 0.0.0.0:6996 0.0.0.0:* LISTEN 22065/lwfs tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 38296/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5278/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 5013/cupsd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 5962/master tcp 0 0 0.0.0.0:8666 0.0.0.0:* LISTEN 44868/lwfs tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 22065/lwfs  

转载于:https://www.cnblogs.com/EveningWind/p/10607966.html

最新回复(0)