代码之家  ›  专栏  ›  技术社区  ›  Vikrant Chaudhary

如何从终端启动命令,使终端不是父终端?

  •  25
  • Vikrant Chaudhary  · 技术社区  · 17 年前

    1. 我打开终端
    2. 我写 example-command 示例命令
    3. 示例命令
    4. example-command &

    8 回复  |  直到 16 年前
        1
  •  28
  •   Community Mohan Dere    9 年前

    有两种方法,结果相同。

    1. nohup 当你启动程序时。例如。, nohup example-command
    2. 或者, as @alamar noted disown 命令。不幸的是,据我所知, 是bash特有的;如果你使用另一个shell,比如 tcsh ,您可能会被限制在 上面的形式。
        2
  •  11
  •   Bash    17 年前

    请先搜索类似的问题。

    除了上面列出的方法外,您还可以:

    setsid command_name
    

    例如:

    setsid xclock
    

    谢谢

        3
  •  7
  •   Elijah Lynn    12 年前

    在Zsh(不是bash)中,你可以:

    example-command &; disown {pid}
    

    或者只是

    example-command &; disown
    
        4
  •  5
  •   MatthieuP    17 年前

    你也可以考虑使用 screen 命令。

        5
  •  1
  •   hiena    17 年前

        6
  •  1
  •   Shane C. Mason    17 年前

    您还可以使用 'at' or 'batch' commands

        7
  •  1
  •   Aiden Bell    17 年前

    disown是内置的bash。您可以为命令创建一个包装器shellscript,例如

    #!/bin/bash
    $1 &
    P=`which $1`
    disown `pidof ${P}`
    

    不是最健壮的脚本(无论如何),但可能有助于你继续前进。例如:

    $./launch_script.sh myProgram
    

    如果您正在编辑程序,也可以在程序源代码中执行此操作。

        8
  •  -2
  •   Eduardo    17 年前

    运行:示例命令

    按键:Control-Z

    运行:bg