假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,telne)

sh/bash/dash/ksh/zsh等Shell脚本
回复
cxytz01
帖子: 45
注册时间: 2008-01-26 11:26

假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,telne)

#1

帖子 cxytz01 » 2012-11-26 10:36

假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,telnet断开连接),那么程序会怎么样? 程序会被终止吗?
cxytz01
帖子: 45
注册时间: 2008-01-26 11:26

Re: 假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,te

#3

帖子 cxytz01 » 2012-11-26 11:04

cxytz01 写了:假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,telnet断开连接),那么程序会怎么样? 程序会被终止吗?

忘了补充下,我的程序不是精灵程序。就是普通的程序。
头像
yaoms
帖子: 4952
注册时间: 2007-10-19 14:51
来自: 深圳

Re: 假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,te

#4

帖子 yaoms » 2012-11-26 11:36

用 nohug 启动就不会给挂掉。screen里也可以幸存
Nothing 有事请发邮件到 yms541 AT gmail.com
alias 爱慕颇雷尔='mplayer'
zhangxiaofir
帖子: 53
注册时间: 2010-12-09 23:54

Re: 假设通过ssh,telnet连接服务器运行程序(程序运行过程中不需要与终端交互),如果此时网络断了(ssh,te

#5

帖子 zhangxiaofir » 2012-11-26 16:14

经测试 在终端运行find 命令 查找很多文件 然后在虚拟机里能查到find进程 将虚拟机网络断掉后 进程被杀死。 ls说的nohug 没有找到 倒是找到个nohup
NOHUP(1) User Commands NOHUP(1)

NAME
nohup - run a command immune to hangups, with output to a non-tty

SYNOPSIS
nohup COMMAND [ARG]...
nohup OPTION

DESCRIPTION
Run COMMAND, ignoring hangup signals.

--help display this help and exit

--version
output version information and exit

If standard input is a terminal, redirect it from /dev/null. If stan-
dard output is a terminal, append output to ‘nohup.out’ if possible
‘$HOME/nohup.out’ otherwise. If standard error is a terminal, redirect
it to standard output. To save output to FILE, use ‘nohup COMMAND >
FILE’.

NOTE: your shell may have its own version of nohup, which usually
supersedes the version described here. Please refer to your shell’s
documentation for details about the options it supports.
回复