#!/bin/bash
process_name=chromedriver
process_name2=webdriver
#查找并杀死进程名
PID=`ps -ef |grep $process_name|grep -v grep|awk '{print $2}'|xargs`
PID2=`ps -ef |grep $process_name2|grep -v grep|awk '{print $2}'|xargs`
save_file="/usr/local/software/ship/sadmin/clean/cleanlog.log"
current_time=$(date "+%Y-%m-%d %H:%M:%S")
#判断进程号是否存在
if [[ -z $PID ]]; then
echo -e "\n\n\n【$current_time】暂无可删除的$process_name记录" >> $save_file
else
kill -9 $PID
echo -e "\n\n\n【$current_time】已删除$process_name的【$PID】进程" >> $save_file
PID_NOW=`ps -ef |grep $process_name|grep -v grep|awk '{print $2}'|xargs`
echo -e "-------------------当前$process_name有【$PID_NOW】进程" >> $save_file
fi
if [[ -z $PID2 ]]; then
echo -e "\n\n\n【$current_time】暂无可删除的$process_name2记录" >> $save_file
else
kill -9 $PID2
echo -e "\n\n\n【$current_time】已删除$process_name的【$PID2】进程" >> $save_file
PID_NOW2=`ps -ef |grep $process_name2|grep -v grep|awk '{print $2}'|xargs`
echo -e "-------------------当前$process_name有【$PID_NOW2】进程" >> $save_file
fi
日志打印信息