shell定时任务
--crontab日志查看tail -f /var/log/cron
--服务启动
service crond start
--编辑服务
crontab -e
--shell命令权限设置
chmod 755 mysql_job.sh
--定时任务调用shell
*/1 * * * * /bin/sh /data/dmp-event-test/dmp-smart-recommend-etl/controller/mysql_job.sh start
#!/bin/sh
lock="push_off_daily_job.py"
#启动服务方法
start(){
echo "service start...."
cd /data/dmp-event-test/dmp-smart-recommend-etl/controller/
su root -c "python push_off_daily_job.py &"
}
#停止服务
stop(){
echo "service stop...."
ID=`ps -ef|grep $lock|grep -v grep|grep -v PPID|awk '{ print $2}'`
for id in $ID
do
kill -9 $id
echo "killed $id"
done
echo "---------------"
}
#重新启动
restart(){
stop
start
}
case "$1" in
"start")
start
;;
"stop")
stop
;;
"restart")
restart
;;
*)
echo "$0 start|stop|restart"
;;
esac
页:
[1]