在后台运行脚本? [英] Run script in background?

查看:160
本文介绍了在后台运行脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题:有没有一种方法来与输出端子运行后台运行一个脚本

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

更多的细节和背景:我有一个应用程序,读取应用程序.log文件,并从中puled信息,然后提供从日志中的信息资料和统计数据。
该应用的更新改变.log文件写入和删除信息,并复制在日志中,我已经无法predict的方式方法。

More detail and background: I had an app that read an apps .log file and puled information from it, then provide information and statistics from the information in the log. An update to the app changed the way the .log file was written and delete information and duplicates the log in a manner that i have been unable to predict.

这是设计的日志接口应用程序并不codeD来检查这些变化。所以当它试图停止工作日志变更后收集信息。

the app that was designed to interface with the log was not coded to check for such changes. so when it attempts to gather information after the log change it stops working.

一个黑客已经设计运行tail -f命令,然后诅咒的应用程序在新的文件指向。
(在黑客的作品)
我想在后台运行的尾巴,使用户不中断它...打破它...

A "hack" has been devised to run a tail -f, then hexed the app to point at the new file. (The "hack" works) I would like to run the tail in the background so that the user doesn't interrupt it... breaking it...

- 对不起长于所需的(可能)的描述。但我想更详细的问题会得到我一个precise答案。

-sorry for the (possibly) longer than needed description. BUt i figured a more detailed question would get me a precise answer.

在此先感谢!

〜¥oseph

推荐答案

问题的答案取决于你需要能够重新连接到进程退出后壳。如果进程非交互式和可以简单地被单独留在家中,然后点的nohup程序和放大器;应该做的伎俩。但是,这不会让你继续与该程序进行交互,你已经关闭后壳。

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.

如果它是一个互动节目,那么最好的办法是使用屏幕或其它终端复用器之一。你开始屏幕,它为您提供了一个新的shell,在这一点,你开始你想要的任何程序,通常的方式,说纳米myfile.txt的。

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".

当您想要关闭的外壳,但保持程序的运行,你preSS C-A D('分离')从屏幕上分离。它会继续运行,但会在后台,并会继续运行,即使你退出。

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.

在后来又想重新连接到屏幕上,您打开一个新的外壳,输入屏幕-r(重新连接),这让你找到你在哪里。

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.

这篇关于在后台运行脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆