note 125937 added to function.cli-set-process-title

From: Date: Wed, 17 Mar 2021 10:04:16 +0000
Subject: note 125937 added to function.cli-set-process-title
Groups: php.notes 
Request: Send a blank email to php-notes+get-219180@lists.php.net to get a copy of this message
In Linux this command changes the title for commands like 'ps -a' it doesn't seem to work with 'top' or 'pkill' To change the short name (eg PHP) to something else you can use the below: <?php $strNewName='myscript'; cli_set_process_name($strNewName); cli_set_process_title($strNewName); var_dump(cli_get_process_name()); var_dump(cli_get_process_title()); function cli_set_process_name($strName) { file_put_contents("/proc/".getmypid()."/comm",$strName); } function cli_get_process_name() { return(trim(file_get_contents("/proc/".getmypid()."/comm"),"\r\n")); } Note: The above will NOT work in Windows and may not work in all flavours of linux (I use Debian). ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.247 (proxied: 220.240.153.139) ---- Manual Page -- http://php.net/manual/en/function.cli-set-process-title.php Edit -- https://master.php.net/note/edit/125937 Del: integrated -- https://master.php.net/note/delete/125937/integrated Del: useless -- https://master.php.net/note/delete/125937/useless Del: bad code -- https://master.php.net/note/delete/125937/bad+code Del: spam -- https://master.php.net/note/delete/125937/spam Del: non-english -- https://master.php.net/note/delete/125937/non-english Del: in docs -- https://master.php.net/note/delete/125937/in+docs Del: other reasons-- https://master.php.net/note/delete/125937 Reject -- https://master.php.net/note/reject/125937 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#219180) next »