当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 2 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : jobs -x command 的作用是什么?说明不太理解,实验也没弄明白
帖子发表于 : 2016-07-28 11:08 

注册: 2013-05-26 6:58
帖子: 2158
系统: Debian 9
送出感谢: 894
接收感谢: 30
jobs -x command 的作用是什么?说明不太理解,实验也没弄明白
代码:
$ help jobs
jobs: jobs [-lnprs] [jobspec ...] or jobs -x command [args]
    Display status of jobs.
   
    Lists the active jobs.  JOBSPEC restricts output to that job.
    Without options, the status of all active jobs is displayed.
   
    Options:
      -l   lists process IDs in addition to the normal information
      -n   lists only processes that have changed status since the last
       notification
      -p   lists process IDs only
      -r   restrict output to running jobs
      -s   restrict output to stopped jobs
   
    If -x is supplied, 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.
   
    Exit Status:
    Returns success unless an invalid option is given or an error occurs.
    If -x is used, returns the exit status of COMMAND.

但是我加上 -x参数后,command接收到的参数好像没有变化
我是到proc里看命令进程的"cmdline"文件


_________________
Linux桌面优化综合贴[2017.09.18](欢迎各位补充或指正误区)
[2016.03.10]会C语言但看不懂英文文档的点这里,一个用C语言编写的简陋学习工具
单硬盘通过iso文件实机安装Debian的方法
重启或操作fcitx时失去响应的一个解决方法,不妨试试看


页首
 用户资料  
 
2 楼 
 文章标题 : Re: jobs -x command 的作用是什么?说明不太理解,实验也没弄明白
帖子发表于 : 2016-07-28 12:12 
头像

注册: 2011-03-20 13:12
帖子: 4521
地址: 山东省寿光县
系统: Debian
送出感谢: 105
接收感谢: 997
就是参数替换的作用
将 %n %str %?str %% %+ %- 替换成对应的PID
代码:
$ cat bin/mytest
#!/bin/bash
echo args: $*
sleep 3600

$ elinks
[1]+  Stopped                 elinks
$ pgrep elinks
30659
$ jobs -x mytest %elinks
args: 30659
$ pgrep mytest
31010
$ cat /proc/31010/cmdline
/bin/bash /home/alex/bin/mytest 30659

$ nano
Use "fg" to return to nano.
[2]+  Stopped                 nano
$ pgrep nano
8930
$ jobs -x mytest %2
args: 8930
$ pgrep mytest
9010
$ cat /proc/9010/cmdline
/bin/bash /home/alex/bin/mytest 8930

$ jobs -x kill %1
[1]-  Exit 2                  elinks
$ jobs -x kill -SIGKILL %2
[1]+  Killed                  nano


参考 http://mywiki.wooledge.org/BashGuide/JobControl


_________________
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户



_________________
评价: 3.7% 科学之子
 
页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 2 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 1 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译