&
&
,发现命令执行时间很长,可以参考本文Ctrl + Z
)bg x
)exit
命令退出当前shell,进程不退出使用Ctrl + Z
将命令暂停切换到后台。Ctrl + Z
是将任务中止(暂停的意思),但是此任务并没有结束,他仍然在进程中他只是维持挂起的状态
shell> wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
--2022-08-06 10:56:21-- https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
Resolving download.filezilla-project.org (download.filezilla-project.org)... 49.12.121.47, 2a01:4f8:242:52d0::2
Connecting to download.filezilla-project.org (download.filezilla-project.org)|49.12.121.47|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11854128 (11M) [application/x-msdos-program]
Saving to: ‘FileZilla_3.60.2_win64_sponsored-setup.exe.2’
1% [> ] 122,880 30.2KB/s eta 6m 19s
^Z (输入Ctrl + Z)
[1]+ Stopped wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
shell> jobs -l
[1]+ Stopped wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
[1]
表示进程在后台的编号为1
shell> fg 1
wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
3% [====> ] 409,600 992B/s in 6m 53s
2022-08-06 11:03:16 (992 B/s) - Connection closed at byte 409600. Retrying.
--2022-08-06 11:03:17-- (try: 2) https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe
Connecting to download.filezilla-project.org (download.filezilla-project.org)|49.12.121.47|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 11854128 (11M), 11444528 (11M) remaining [application/x-msdos-program]
Saving to: ‘FileZilla_3.60.2_win64_sponsored-setup.exe.2’
7% [+++++=====> ] 860,160 28.1KB/s eta 5m 16s
fg 1
中的1
为进程在后台的编号shell> bg 1
[1]+ wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe &
1% [> ] 122,880 534B/s eta 6h 5m [
5% [=======> ] 630,784 19.6KB/s eta 73m 5s
bg 1
中的1
为进程在后台的编号查看后台的进程:
[1]+ Running wget https://download.filezilla-project.org/client/FileZilla_3.60.2_win64_sponsored-setup.exe &
bg 1
后,系统在命令后面加入&
符号&
符号后,此时可以通过exit
命令退出当前shell。执行exit
退出shell后,进程不退出。ps -ef|grep wget
可查看到在后台运行的进程。