Run script in background?

前端 未结 1 457
猫巷女王i
猫巷女王i 2021-01-14 17:49

Simple question: Is there a way to run a script in the background with out terminal running?

More detail and background: I had an app that read an apps .log file and

相关标签:
1条回答
  • 2021-01-14 18:29

    The answer depends on if you need to be able to re-connect to the process after exiting the shell. If the process is non-interactive and can simply be left alone, then "nohup program &" should do the trick. But that won't let you continue to interact with the program after you've closed the shell.

    If it's a interactive program, then your best bet is to use screen or one of the other terminal-multiplexers. You start "screen" which gives you a new shell, in this you start whatever program you want, the usual way, say "nano myfile.txt".

    When you want to close the shell, but leave the program running, you press C-a d ('Detach') to detach from screen. it keeps running, but in the background, and will keep running even if you log out.

    When you then later want to reconnect to screen you open a new shell and type "screen -r" (reconnect), this leaves you right where you where.

    Screen also lets you run several different shells in a single terminal-window and is a neat tool overall. Check it out.

    0 讨论(0)
提交回复
热议问题