如何使python进程以正确的进程名称运行? [英] How do I make python processes run with correct process name?

查看:61
本文介绍了如何使python进程以正确的进程名称运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Python中有一些长期的过程和临时过程.尽管Shell和C程序以它们自己的名称运行,但是所有Python进程都以"python filename.py"运行,这使得识别进程非常困难.

I have a few long term processes and temporary processes in Python. While shell and C programs run under their own names, all Python processes run as 'python filename.py', which makes it tough to identify processes.

如何在Linux中将python进程显示为'logserver.py'或类似名称?我在Ubuntu 11.10中使用Python 2.7.

How can I make python processes show up as 'logserver.py' or such in Linux? I use Python 2.7 in Ubuntu 11.10.

推荐答案

在相关的Python文件中添加一个Shebang,使Python文件可执行(例如,通过 chmod a + x ./logserver.py),然后直接通过 ./logserver.py .

Add a shebang to the Python file in question, make the Python file executable (e.g. by chmod a+x ./logserver.py) and start it directly by ./logserver.py.

shebang是告诉内核使用哪个解释器的行.这只是文件开头的类似#!/usr/bin/env python 的行.

A shebang is a line telling the kernel which interpreter to use. It's simply a line like #!/usr/bin/env python at the very beginning of the file.

这篇关于如何使python进程以正确的进程名称运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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