Home>Article>Backend Development> How to loop through the memory usage of php-fpm

How to loop through the memory usage of php-fpm

藏色散人
藏色散人 forward
2020-01-27 17:03:26 2247browse

How to loop through the memory usage of php-fpm

webmail的业务中进行发信,如果携带了附件,会把附件拼接内嵌到邮件正文里,这时会极大的占用内存,可以使用以下命令查看fpm的进程内存占用

ps --no-headers --sort -rss -o "rss,pid,cmd" -C php-fpm

这句的意思是,打印rss,pid,cmd列,并且按rss进行排序,rss就是占用的内存量

awk '{printf("%dM %s\n",$1/1024,$0)}'

这句的意思是,循环每一行结果,并且把kb换算成Mb,$0代表这行数据

while true;do clear;date;ps --no-headers --sort -rss -o "rss,pid,cmd" -C php-fpm|awk '{printf("%dM %s\n",$1/1024,$0)}';sleep 1;done

当进行发信操作时可以看到内存占用情况

How to loop through the memory usage of php-fpm

更多相关php知识,请访问php教程

The above is the detailed content of How to loop through the memory usage of php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete