ps -eo lstart 启动时间
ps -eo etime 运行多长时间.
ps -eo pid,lstart,etime | grep PID
ps -eO lstart |grep ''
写个小脚本,根据传入的参数显示对应进程的启动时间
比如运行:./show.sh mysql 显示mysql进程的启动时间:
- #!/bin/bash
- if [ -z $1 ]; then
- echo "please input ps keyword" && exit 1
- fi
- ps aux |grep $1 |grep -v "grep $1" |grep -v " $1" |while read line
- do
- linewords=($line)
- pid="${linewords[1]}"
- START_TIME=$(ps -p ${pid} -o lstart | grep -v "START")
- echo "$line $START_TIME"
- done
本文介绍了一个简单的Shell脚本,该脚本可以根据输入的进程名称查询并显示其启动时间。通过使用ps命令结合grep进行过滤,脚本能够准确地定位到目标进程,并输出其启动的具体时间。
5350

被折叠的 条评论
为什么被折叠?



