别忘了在disown之前执行bg命令,否则进程会一直stopped

别忘了在disown之前执行bg命令,否则进程会一直stopped

今天在Linux下测试程序,是直接执行的命令,如下所示:

[root@NODE22 bin]# ./cap
#======= CAP v20120216f =======#
prog-path: /root/work22/ct08/bin/
prog-name: cap
cfg_name='../cfg/cap.cfg'
loadconfig ok
checkconfig ok
System::Init ok
cap start ok, pid 8342

想到这个程序要在我下班之后继续执行,于是我就按下了Ctrl+Z

 


[1]+  Stopped                 ./cap

 

因为我准备关闭SecureCRT准备收工了,所以决定让它脱离我这个终端,执行了disown来做这件事

[root@NODE22 bin]# disown %1
-bash: warning: deleting stopped job 1 with process group 8342
[root@NODE22 bin]#

 

看看这个操作灵不灵,我看了一下日志,发现日志没有继续往下记录,正常情况应该往下记录的。

 

想起来,没有在disown之前执行bg命令,程序已经处于Stopped状态(看disown命令的输出),得让它继续往下执行

 

[root@NODE22 bin]# killall -CONT cap

 

日志也正常了。切记啊,切记啊:别忘了在disown之前执行bg命令

 

 

本文地址: http://codingstandards.iteye.com/blog/1408321

 

 

相关帮助信息:

[root@NODE22 eap_designer]# help disown
disown: disown [-h] [-ar] [jobspec ...]
    By default, removes each JOBSPEC argument from the table of active jobs.
    If the -h option is given, the job is not removed from the table, but is
    marked so that SIGHUP is not sent to the job if the shell receives a
    SIGHUP.  The -a option, when JOBSPEC is not supplied, means to remove all
    jobs from the job table; the -r option means to remove only running jobs.
[root@NODE22 eap_designer]# help bg
bg: bg [job_spec ...]
    Place each JOB_SPEC in the background, as if it had been started with
    `&'.  If JOB_SPEC is not present, the shell's notion of the current
    job is used.
[root@NODE22 eap_designer]# help fg
fg: fg [job_spec]
    Place JOB_SPEC in the foreground, and make it the current job.  If
    JOB_SPEC is not present, the shell's notion of the current job is
    used.
[root@NODE22 eap_designer]# help jobs
jobs: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
    Lists the active jobs.  The -l option lists process id's in addition
    to the normal information; the -p option lists process id's only.
    If -n is given, only processes that have changed status since the last
    notification are printed.  JOBSPEC restricts output to that job.  The
    -r and -s options restrict output to running and stopped jobs only,
    respectively.  Without options, the status of all active jobs is
    printed.  If -x is given, COMMAND is run after all job specifications
    that appear in ARGS have been replaced with the process ID of that job's
    process group leader.
[root@NODE22 eap_designer]#

 

 

 

你可能感兴趣的:(Linux问题)