Run python as a daemon process
I am using `&`: why isn't the process running in the background?
- Uninteresting
- Misleading
- Offensive
- Repetitive
- Other

|
I know that I can append I'm SSH'ing into an Ubuntu 12.04 box and running a python program with Why is this? I am using the ampersand to run the process in the background. How can I get it to run regardless of if I am SSH'ed in? |
|||||||||
|
|
When you close a terminal window, the terminal emulator sends a SIGHUP to the process it is running, your shell. Your shell then forwards that SIGHUP to everything it's running. On your local system, this is the ssh. The ssh then forwards the SIGHUP to what it's running, the remote shell. So your remote shell then sends a SIGHUP to all its processes, your backgrounded program. There are 2 ways around this.
Additionally you must make sure that your program doesn't write to the terminal through STDOUT or STDERR, as both of those will no longer exist once the terminal exits. If you don't redirect them to something like |
|||||||||||||||||
|
- Uninteresting
- Misleading
- Offensive
- Repetitive
- Other

|
The process is running in the background in the terminal, but the output from
In your case this would be:
|
||||
|
|
|
When you logout, background processes associated with the login session are normally killed as well. If you want them to be disconnected from the session, run them with
|
||||
|
|
|
The So, when you close the shell which started those children, the children will be closed also. What you appear to want is a daemon process, which is significantly more tricky because it needs to dissociate entirely from the parent process. The shell usually doesn't have a simple way of doing that. |
|||
|
|
|
After the command ending with ampersand (&), at the command prompt run the command "bg" bash> python program.py & bash> bg This will put the "&" command to the background bash> jobs This will list the jobs running in the background bash> fg 1 This will bring Job #1 to the foreground Another way, (to be able to log out) bash> at now bash> /full/path/python /full/path/program.py bash> ^d |
Run python as a daemon process的更多相关文章
- A daemon process class in python
In everbright task schedule project, we need some daemon process to do certain work, here is a examp ...
- python中的daemon守护进程实现方法
原文参考:http://blog.csdn.net/tao_627/article/details/49532021 守护进程是生存期长的一种进程.它们独立于控制终端并且周期性的执行某种任务或等待处理 ...
- 越狱开发-创建真正的后台程序(Daemon Process)
在网上搜索了一下如何在IOS上面实现Daemon Process,只有chrisalvares的博客中有过详细的描述,但是其博客中描述的较为复杂, 参考stackoverflow中的一个问答: htt ...
- ionic android - Unable to start the daemon process. Could not reserve enough space for 2097152KB object heap
Unzipping C:\Users\app\.gradle\wrapper\dists\gradle-4.1-all\bzyivzo6n839fup2jbap0tjew\gradle-4.1-all ...
- Android Studio: Failed to sync Gradle project 'xxx' Error:Unable to start the daemon process: could not reserve enough space for object heap.
创建项目的时候报错: Failed to sync Gradle project 'xxx' Error:Unable to start the daemon process: could not r ...
- Android Studio新建了一个项目提示Error:Unable to start the daemon process
提示如下错误:
- python 守护进程 daemon
python 守护进程 daemon # -*-coding:utf-8-*- import sys, os '''将当前进程fork为一个守护进程 注意:如果你的守护进程是由inetd启动的,不要这 ...
- 【error】Gradle sync failed: Unable to start the daemon process.【已解决】
---恢复内容开始--- 在克隆GIT项目后,Android Studio 报错: Gradle sync failed: Unable to start the daemon process. Th ...
- How to run Python code from Sublime
How to run Python Code from Sublime,and How to run Python Code with input from sublime Using Sublime ...
随机推荐
- algo_预备
章 C + +程序设计 大家好!现在我们将要开始一个穿越" 数据结构.算法和程序" 这个抽象世界的特殊旅程,以解决现实生活中的许多难题.在程序开发过程中通常需要做到如下两点:一是高 ...
- ionic hybrid备忘
ionic 是目前最有潜力的一款开源Hybrid( HTML5+css3+nodejs+Angularjs+PhoneGap)手机应用开发框架.通过 SASS 构建应用程序,它提供了很多 UI 组件来 ...
- Oracle 10gR2 & 10.2.0.5 的百度网盘下载地址 :)
如题: https://pan.baidu.com/s/1eSI770m
- WebDriver基本API使用(基于Java)V1.0
WebDriver基本API使用(基于Java)V1.0http://www.docin.com/p-803032877.html
- [转] 关于hibernate的缓存使用
http://blog.csdn.net/woshichenxu/article/details/586361 1. 关于hibernate缓存的问题: 1.1.1. 基本的缓 ...
- 网络安装archlinux(2012.8.20)笔记
周末闲极无聊,把烂笔记本翻出来想装个Archlinux,发现USB不能启动,光驱也挂了,只好网络安装. 我先后试了两种安装方式,一种纯互联网启动,安装,一种局域网启动,再互联网安装.分别说说. 不管哪 ...
- jsp页面间传递参数 中文乱码问题(zz)
jsp页面间传递参数 中文乱码问题 1.传递参数 var url = "*****Test.jsp?param1="+encodeURI(encodeURI(str));//对 ...
- Raspberry Pi --操作LED
最简单的一个树莓派GPIO操作入门,这里记录以下 先上连接图: 卧槽.图真特么的大 用到了GPIO的GND和#18针脚,这就不上图了,红色的线接的是18针脚,暗色的线接的是GND针脚,下面上Pytho ...
- 我是如何用Go语言搭建自己的博客的
前言: 话说,已经很久没有在博客园更新博客了,之前写的关于go语言的系列学习文章<让我们一起Go>也由于种种原因一度中断.但是,正如我之前在文章中所写,可以慢慢来,但是对于Go语言的学习却 ...
- Java知多少(完结)
系列文章: Java知多少(上) Java知多少(中) Java知多少(下)

