首先新建一个shell脚本
touch tuncate.sh
然后 vim truncate.sh
加入shell 脚本
#!/bin/bash
#先停止守护进程
ps -ef|grep java |grep com.vodsys.timer.util.TimerListener |awk '{system("kill -9 "$2)}'
sleep 2s
#连接数据库
mysql -uroot -p123456 <<EOF
use vodsys;
truncate table exp_course;
delete table student;
EOF
#开启守护进程
/var/lib/tomcat8/webapps/VODSYS/WEB-INF/classes/TimerListener.sh