服务器上某个进程杀掉后会重启,怀疑是被当成肉鸡,因此是用linux自带的crontab定时执行脚本杀掉进程
上传脚本文件到服务器
#! /bin/bash
# 要杀掉进程的名称
APPLICATION="ntools"if pkill -f "${APPLICATION}"; thenecho "${APPLICATION} stopped successfully"
elseecho "${APPLICATION} is already stopped or not found"
fi
给文件付可执行权限
chmod +x kill_ntools
配置/etc/crontab(每分钟执行一次)
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root# For details see man 4 crontabs# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
* * * * * root /home/kill_ntools.sh