linux获取进程到现在已启动秒数

获取关键字tomcat进程启动时间(单位秒)

ps -ef | grep tomcat | grep -v grep | awk '{print $2}' | xargs -i ps -p {} -oetime= | tr '-' ':' | awk -F: '{ total=0; m=1; } { for (i=0; i < NF; i++) {total += $(NF-i)*m; m *= i >= 2 ? 24 : 60 }} {print total}'

You may also like...