Bash触发器wget命令并且不等待响应,继续执行下一个命令

时间:2020-12-01 16:24:05

Is there a way I can trigger a wget command via bash script and continue to the next command in the bash script without waiting for a response from the wget? i am executing a command which should take lots of time and don't want wget to hold for a response nor re-trigger it after timeout has been timeout limit

有没有办法可以通过bash脚本触发wget命令并继续执行bash脚本中的下一个命令而无需等待wget的响应?我正在执行一个命令,该命令应该花费大量时间,并且不希望wget保持响应,也不要在超时超时限制后重新触发它

1 个解决方案

#1


You should use the --background option, as it goes to background and saves the output to a log

您应该使用--background选项,因为它转到后台并将输出保存到日志中

--background
       Go to background immediately after startup.  If no output file is specified via the -o, output is redirected to wget-log

Example:

$ wget http://cdimage.ubuntu.com/ubuntu-server/daily/current/wily-server-ppc64el.iso --background
Continuing in background, pid 79783.
Output will be written to ‘wget-log’.

$ cat wget-log 
--2015-05-12 11:21:35--  http://cdimage.ubuntu.com/ubuntu-server/daily/current/wily-server-ppc64el.iso
Resolving cdimage.ubuntu.com (cdimage.ubuntu.com)... 91.189.92.164, 2001:67c:1360:8c01::1f
Connecting to cdimage.ubuntu.com (cdimage.ubuntu.com)|91.189.92.164|:80... connected.
....

#1


You should use the --background option, as it goes to background and saves the output to a log

您应该使用--background选项,因为它转到后台并将输出保存到日志中

--background
       Go to background immediately after startup.  If no output file is specified via the -o, output is redirected to wget-log

Example:

$ wget http://cdimage.ubuntu.com/ubuntu-server/daily/current/wily-server-ppc64el.iso --background
Continuing in background, pid 79783.
Output will be written to ‘wget-log’.

$ cat wget-log 
--2015-05-12 11:21:35--  http://cdimage.ubuntu.com/ubuntu-server/daily/current/wily-server-ppc64el.iso
Resolving cdimage.ubuntu.com (cdimage.ubuntu.com)... 91.189.92.164, 2001:67c:1360:8c01::1f
Connecting to cdimage.ubuntu.com (cdimage.ubuntu.com)|91.189.92.164|:80... connected.
....