shell 练习 - 第七周
1、 用shell实现传入进程pid, 查看对应进程/proc下CPU、内存指标 #!/bin/bash read -p "Input PID Value: " pid pid_exist=`ps aux|awk '{print $2}'|grep -w $pid` if [ ! $pid_exist ];then echo "$pid is not exist!!" else echo "Memory Usage :" cat /proc/$pid/status | grep ^Vm echo "Cpu Usage : " echo "PID LWP %CPU :" ps -eLo pid,lwp,pcpu | grep $pid fi 2、 编写Nginx的systemd配置文件, 实现nginx进程开机启动 #安装nginx yum install nginx #编写脚本 vim /etc/systemd/system/nginx.service #描述相关 [Unit] Description=nginx After=network.target #脚本 [Service] Type=forking ExecStart=/usr/sbin/nginx ExecReload=/usr/sbin/nginx reload ExecStop=/usr/sbin/nginx