当前位置:网站首页>后台运行程序方法
后台运行程序方法
2022-07-16 06:18:00 【Alkali!】
(cmd &)
每一个命令行终端都是一个 shell 进程,你在这个终端里执行的程序实际上都是这个 shell 进程分出来的子进程。正常情况下,shell 进程会阻塞,等待子进程退出才重新接收你输入的新的命令。加上&号,只是让 shell 进程不再阻塞,可以继续响应你的新命令。但是无论如何,你如果关掉了这个 shell 命令行端口,依附于它的所有子进程都会退出。
而(cmd &)这样运行命令,则是将cmd命令挂到一个systemd系统守护进程名下,认systemd做爸爸,这样当你退出当前终端时,对于刚才的cmd命令就完全没有影响了。
nohup
nohup some_cmd &
nohup 的原理也很简单,终端关闭后会给此终端下的每一个进程发送SIGHUP信号,而使用nohup运行的进程则会忽略这个信号,因此终端关闭后进程也不会退出。
比较
(cmd &)这种形式更加稳定
边栏推荐
猜你喜欢

HMM & MEMM & CRF

Desai wisdom number - histogram (positive and negative bar graph): expectation & actual salary of 2022 graduates in different cities
![Nc16857 [noi1999] birthday cake](/img/40/95b3a62c829f352bd8e85943d01c5c.png)
Nc16857 [noi1999] birthday cake

After 2000, he was hired as a special associate researcher of Nanjing University. He went to primary school at the age of 4 and was admitted to Nanjing University at the age of 14!

Comparison and summary of five deep learning models for time series prediction: from simulated statistical model to unsupervised model that can be pre trained

IDEA集成Gerrit插件

Codeforces Round #805 A - G

小程序毕设作品之微信评选投票小程序毕业设计(8)毕业设计论文模板

Win11 system How to enable Net Framework 3.5?

The first one in the whole network: how to avoid app crash due to calling unimplemented class methods
随机推荐
学习路之PHP--post获取不到请求数据
Design of hydrogen monitoring system based on single chip microcomputer (0490)
Is it safe for Huatai Securities to open an account? Is it a regular securities company?
Kotlin | launch build report for kotlin compiler task
antd a-upload 多选multiple为ture时 限制上传个数
Is there a trap for Huatai Securities to open an account? Is it safe to open an account online?
4. Redis architecture design to use scenarios - string, list, set, Zset, hash use scenarios
全网首发独发:如何避免因为调用了没有实现的类方法而造成APP崩溃
2022T电梯修理操作证考试题及在线模拟考试
STM32应用开发实践教程:基于 RS-485 总线的多机通信应用开发
QT custom control -- pagenavigation
05-GuliMall VirtualBox给虚拟机设置固定IP
thinkphp5.1.37反序列化链子分析
Design of hydrogen monitoring and alarm system based on single chip microcomputer (0492)
vivado里那些看不懂的约束语句
分库分表和 NewSQL 到底怎么选?
Hal firmware library
How to turn off win11 system protection? Win11 system protection shutdown method
关于mock第三方调用
How does DMS empower database functions?