更改python脚本的进程名称 [英] changing the process name of a python script

查看:981
本文介绍了更改python脚本的进程名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改在Linux上运行python脚本的进程的名称?

Is there a way to change the name of a process running a python script on Linux?

当我执行ps时,我得到的只是"python"进程名称.

When I do a ps, all I get are "python" process names.

推荐答案

http://code.google .com/p/procname/

样品用量:

# Lets rename:    
>>> procname.setprocname('My super name')    

# Lets check. Press Ctrl+Z       
user@comp:~/procname$ ps

    PID TTY TIME CMD 

13016 pts/2 00:00:00 bash

13128 pts/2 00:00:00 My super name <-- it's here

它将仅在存在prctl系统调用并支持PR_SET_NAME命令的系统上工作.

It will only work on systems where prctl system call is present and supports PR_SET_NAME command.

这篇关于更改python脚本的进程名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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