[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [HS] comment mettre en arrière plan une commande lancée en interactif dans un e console SSH



François Cerbelle a écrit :
Bulot gregory a écrit :
Bonjour,

désolé pour ce HS. Tout est dans le titre :
j'ai lancé un calcul sur un ordinateur distant via SSH. J'ai fait la
bêtise de ne pas utiliser screen pensant que tout allait bien se
passer...

[désolé pour le mail privé coupé ...]

donc, j'ai pas tester, essayer sur un élément moins critique :
  ctrl+z puis 'bg' (=background), après une déco, vérifier que le process
tourne toujours (ps -aef ?)


Ca ne peut pas marcher car la fermeture de session va tuer le shell qui va envoyer le signal HUP à tous ses fils. C'est pourquoi il existe la commande "nohup" pour executer un process en indiquant qu'il ne doit pas recevoir ce signal :

nohup commande &

Par contre, une fois le processus lancé, je ne sais pas s'il est possible de bloquer le signal. Il faut certainement consulter l'aide de ton shell en recherchant les commandes de gestion des Táches (commandes jobs, fg, bg ... sous bash). Tu y trouveras peut etre ton bonheur.

Fanfan


En faisant la recherche "bash bg nohup hup" dans Google, le premier résultat est de WikiPedia et l'extrait donné par Google est prometteur. La page WikiPedia donne les informations suivantes à tenter :

Existing jobs

Some shells (e.g. bash) provide a shell builtin that may be used to prevent SIGHUP being sent or propagated to existing jobs, even if they were not started with nohup. In bash, this can be obtained by using disown -h job; using the same builtin without arguments removes the job from the job table, which also implies that the job will not receive the signal. Another relevant bash option is shopt huponexit, which automatically sends the HUP signal to jobs when the shell is exiting normally.

Fanfan


Reply to: