Como faço para manter os trabalhos em execução após o logout? [duplicado]

3

Às vezes, conecto-me remotamente ao meu Ubuntu usando o NX. Em seguida, executo alguns trabalhos em segundo plano, por exemplo:

$ /path/to/script.pl &

No entanto, quando eu faço logout, as tarefas param de ser executadas.

Como posso fazer com que eles continuem mesmo depois de sair?

    
por David B 20.09.2010 / 22:47

4 respostas

2

Acho que outra alternativa seria usar screen .

    
por 21.09.2010 / 00:22
3

O shell elimina todos os processos em seu grupo de processos quando termina, enviando SIGHUP.

Se você executar o bash shell, poderá digitar disown para mantê-lo em execução após o logout. Isso remove da lista de processos para os quais enviará sinais.

Ou você pode iniciar o script com nohup , mas é preciso lembrar disso quando executar o comando. Isto diz ao seu comando para ignorar o sinal SIGHUP que o shell irá enviar. Isso funcionará em qualquer shell.

    
por 20.09.2010 / 22:51
1

Você pode usar nohup

nohup /path/to/script.pl &
    
por 21.09.2010 / 01:15
1

Veja " Mantenha os scripts Linux em execução depois de ter fechado um shell remoto " para saber como fazer isso usando o comando screen.

The answer lies in a command line tool called screen.

Screen allows you to start a process on a virtual screen, then detach that screen and do >something else (including log out). You can also reattach your screen after logging out >and logging in again.

If you dont have the screen command on your remote linux box, first install it either from source or using your favourite package manager. Then login into your remote box and run your desired command prefixed with “screen”. For example:

screen top

Now to detach the screen use CTRL+a followed by d. This will detach your screen and you can go about any other business, including quitting your remote session.

Reattaching you screen at any time is as simple as running the command:

screen -r

    
por 27.04.2011 / 08:21

Tags