这篇文章主要讲解了“linux前后台任务实例分析”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux前后台任务实例分析”吧!对于任务的管理,我们一般有如下几个需求:将进程切换到前台将进程
这篇文章主要讲解了“linux前后台任务实例分析”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Linux前后台任务实例分析”吧!
对于任务的管理,我们一般有如下几个需求:
将进程切换到前台
将进程切换到后台
查看后台任务
终止后台任务
为了演示这几个需求,我们搬出伟大的 Hello World 程序:
root@jaking-virtual-Machine:~# ls -l#这三个脚本源码相同total 12-rwxr-xr-x 1 root root 70 Feb 21 17:25 HelloWorld1.sh-rwxr-xr-x 1 root root 70 Feb 21 17:25 HelloWorld2.sh-rwxr-xr-x 1 root root 70 Feb 21 17:26 HelloWorld3.shroot@jaking-virtual-machine:~# cat HelloWorld1.sh#!/bin/bashwhile truedo echo "Hello World!" sleep 1done
开启后台任务
root@jaking-virtual-machine:~# ./HelloWorld1.sh > test1.txt &[1] 65139root@jaking-virtual-machine:~# ./HelloWorld2.sh > test1.txt &[2] 65145root@jaking-virtual-machine:~# ./HelloWorld3.sh > test1.txt &[3] 65155
jobs -l 查看后台任务
root@jaking-virtual-machine:~# jobs -l[1] 65139 Running ./HelloWorld1.sh > test1.txt &[2]- 65145 Running ./HelloWorld2.sh > test1.txt &[3]+ 65155 Running ./HelloWorld3.sh > test1.txt &
fg 把指定的后台任务调到前台
root@jaking-virtual-machine:~# fg %2./HelloWorld2.sh > test1.txt^Z#Ctrl + Z将前台任务切到后台并停止运行[2]+ Stopped ./HelloWorld2.sh > test1.txtroot@jaking-virtual-machine:~# jobs -l[1] 65139 Running ./HelloWorld1.sh > test1.txt &[2]+ 65145 Stopped ./HelloWorld2.sh > test1.txt[3]- 65155 Running ./HelloWorld3.sh > test1.txt &
bg 使后台停止运行的任务重新运行
root@jaking-virtual-machine:~# bg %2[2]+ ./HelloWorld2.sh > test1.txt &root@jaking-virtual-machine:~# jobs -l[1] 65139 Running ./HelloWorld1.sh > test1.txt &[2]- 65145 Running ./HelloWorld2.sh > test1.txt &[3]+ 65155 Running ./HelloWorld3.sh > test1.txt &
kill 杀掉后台进程
root@jaking-virtual-machine:~# kill 65145root@jaking-virtual-machine:~# jobs -l[1] 65139 Running ./HelloWorld1.sh > test1.txt &[2]- 65145 Terminated ./HelloWorld2.sh > test1.txt[3]+ 65155 Running ./HelloWorld3.sh > test1.txt &root@jaking-virtual-machine:~# kill %3root@jaking-virtual-machine:~# jobs -l[1]- 65139 Running ./HelloWorld1.sh > test1.txt &[2]- 65145 Terminated ./HelloWorld2.sh > test1.txt[3]+ 65155 Terminated ./HelloWorld3.sh > test1.txt
感谢各位的阅读,以上就是“Linux前后台任务实例分析”的内容了,经过本文的学习后,相信大家对Linux前后台任务实例分析这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!
--结束END--
本文标题: Linux前后台任务实例分析
本文链接: https://www.lsjlt.com/news/315865.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
一口价域名售卖能注册吗?域名是网站的标识,简短且易于记忆,为在线用户提供了访问我们网站的简单路径。一口价是在域名交易中一种常见的模式,而这种通常是针对已经被注册的域名转售给其他人的一种方式。
一口价域名买卖的过程通常包括以下几个步骤:
1.寻找:买家需要在域名售卖平台上找到心仪的一口价域名。平台通常会为每个可售的域名提供详细的描述,包括价格、年龄、流
443px" 443px) https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294.jpg https://www.west.cn/docs/wp-content/uploads/2024/04/SEO图片294-768x413.jpg 域名售卖 域名一口价售卖 游戏音频 赋值/切片 框架优势 评估指南 项目规模
0