Este post é aquela famosa dica de poucas linhas mas que pode ser uma mão na roda em certas horas. E foi o que aconteceu comigo, estava fazendo um download da image do Raspbian (Distribuição Linux da Raspberry PI baseada no Debian) e o download estava em 85%, e eu tinha que sair, porém, o problema é que teria que levar o notebook junto.
Problema não? E ae que lembrei e pensei, hum, porque não enviar um sinal de SIGSTOP e depois quando quisesse voltar enviava um sinal de SIGCONT?
E foi isso que fiz, vamos ver o caso e como realizar o envio deste sinal para o processo. Como exemplo vou começar um download da image Raspbian do Raspberry PI.
cleiton@vm2 ~ $ wget http://downloads.raspberrypi.org/raspbian_latest --2015-05-13 21:19:10-- http://downloads.raspberrypi.org/raspbian_latest Resolving downloads.raspberrypi.org (downloads.raspberrypi.org)... 93.93.128.211, 93.93.128.230, 93.93.130.39, ... Connecting to downloads.raspberrypi.org (downloads.raspberrypi.org)|93.93.128.211|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip [following] --2015-05-13 21:19:11-- http://downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip Reusing existing connection to downloads.raspberrypi.org:80. HTTP request sent, awaiting response... 302 Found Location: http://director.downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip [following] --2015-05-13 21:19:11-- http://director.downloads.raspberrypi.org/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip Resolving director.downloads.raspberrypi.org (director.downloads.raspberrypi.org)... 93.93.128.230, 93.93.130.39, 93.93.130.214, ... Reusing existing connection to downloads.raspberrypi.org:80. HTTP request sent, awaiting response... 302 Moved temporarily Location: http://files.velocix.com/c1410/newdownloads/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip [following] --2015-05-13 21:19:12-- http://files.velocix.com/c1410/newdownloads/raspbian/images/raspbian-2015-05-07/2015-05-05-raspbian-wheezy.zip Resolving files.velocix.com (files.velocix.com)... 212.187.212.226 Connecting to files.velocix.com (files.velocix.com)|212.187.212.226|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://212.187.212.72/bt/0e19598eba0e05d0be045394081575189cdaf075/data/2015-05-05-raspbian-wheezy.zip [following] --2015-05-13 21:19:13-- http://212.187.212.72/bt/0e19598eba0e05d0be045394081575189cdaf075/data/2015-05-05-raspbian-wheezy.zip Connecting to 212.187.212.72:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1038523231 (990M) [application/zip] Saving to: ‘raspbian_latest’ 3% [> ] 32.738.784 148KB/s eta 1h 57m
Pegando o PID do wget e enviando o sinal STOP.
cleiton@vm2 ~ $ pidof wget 3549 cleiton@vm2 ~ $ kill -STOP 3549
E no terminal com wget ficou assim:
Saving to: ‘raspbian_latest’ 3% [> ] 32.738.784 148KB/s eta 1h 57m [1]+ Stopped wget http://downloads.raspberrypi.org/raspbian_latest
Para voltar a fazer o download é só enviar o sinal CONT para o PID.
cleiton@vm2 ~ $ kill -CONT 3549
No terminal com o wget:
Saving to: ‘raspbian_latest’ 3% [> ] 32.738.784 148KB/s eta 1h 57m [1]+ Stopped wget http://downloads.raspberrypi.org/raspbian_latest 3% [> ] 33.626.904 3,20KB/s in 8m 47s 2015-05-13 21:28:01 (62,3 KB/s) - Connection closed at byte 33626904. Retrying. --2015-05-13 21:28:02-- (try: 2) http://212.187.212.72/bt/0e19598eba0e05d0be045394081575189cdaf075/data/2015-05-05-raspbian-wheezy.zip Connecting to 212.187.212.72:80... connected. HTTP request sent, awaiting response... 206 Partial Content Length: 1038523231 (990M), 1004896327 (958M) remaining [application/zip] Saving to: ‘raspbian_latest’ 6% [+=> ] 63.629.464 362KB/s eta 44m 28
Dessa maneira comecei o download em casa e acabei em outro local sem perder o que já havia baixado.
Enviando STOP para interromper o processo temporariamente e continuar a execução do processo enviando CONT.
Espero que tenham gostado, até a próxima.
Linux – Pausando e reiniciando um download com wget by Cleiton Bueno is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.