最新 Windows\Linux 后台运行程序注解

简介: 本文介绍了在Windows和Linux系统后台运行程序的方法,包括Linux系统中使用nohup命令和ps命令查看进程,以及Windows系统中通过编写bat文件和使用PowerShell启动隐藏窗口的程序,确保即使退出命令行界面程序也继续在后台运行。

一、前言

有时候需要在后台运行程序,查了查网上现有的程序有些运行不了,跑通了之后简单记录一下,为后面的同学躺一下雷

1、Linux 系统

Linux后台运行进程时,通常使用如下方法:

(1)程序挂后台

nohup "运行的内容" &

下面是运行示例参考

nohup python text.py >/2021out.log &

其他相关的操作

(2)查询挂后台的程序的PID

 ps aux | grep py程序名

示例: ps aux | grep test
在这里插入图片描述

(2)依据PID杀死进程

kill +目标进程

2、Windows系统

1、写成bat指令

新建bat 编辑内容:

 start /B cmd /c + 操作

参考示例:

start /B cmd /c  H:\frp_0.52.2_windows_amd64\frpc.exe -c  H:\frp_0.52.2_windows_amd64\frpc.toml

点击这个bat,测试是否可以运行

2、将bat 指令在powershell 运行

打开powershell执行

Start-Process -WindowStyle hidden -FilePath "第一步创建的bat的绝对地址"

参考示例:
在这里插入图片描述
到这里整个服务就挂到后台了,即使退出powershell后依然运行。

相关文章
|
1月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025080401 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025080401 (Linux, Windows) - 专业渗透测试框架
84 0
|
6天前
|
安全 Ubuntu Linux
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
56 4
Nexpose 8.21.0 for Linux & Windows - 漏洞扫描
|
1月前
|
Java Linux Apache
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
124 5
Apache NetBeans 27 (macOS, Linux, Windows) - Java 等多语言开源跨平台 IDE
|
1月前
|
NoSQL IDE MongoDB
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
66 1
Studio 3T 2025.15 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
11天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
171 0
|
19天前
|
安全 Java Linux
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
38 0
Nexpose 8.19.0 for Linux & Windows - 漏洞扫描
|
安全 Linux 测试技术
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
OpenText Static Application Security Testing (Fortify) 25.3 (macOS, Linux, Windows) - 静态应用安全测试
73 0
|
1月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
105 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
Linux iOS开发 UED
LibreOffice 25.8 (Linux, macOS, Windows) - 自由免费的全能办公套件
LibreOffice 25.8 (Linux, macOS, Windows) - 自由免费的全能办公套件
37 0