批量脚本内容
#!/usr/bin/sh
HOSTNAME='127.0.0.1'
USERNAME='root'
PASSWORD='8dc0be97541b2121'
DATABASE='packs'
QUERY_SQL="SELECT mark FROM sim_app_spidersite ORDER BY id DESC"
DB_DATA=`mysql -h $HOSTNAME -p3306 -u$USERNAME -p$PASSWORD $DATABASE -e "${QUERY_SQL}"`
j=0
for i in ${DB_DATA}
do
((j++))
if((j == 1))
then
continue
fi
/usr/bin/php /www/wwwroot/cpacks/index.php spiders $i
done
执行cron
#进入定时任务编辑页面
crontab -e
#写入定时计划
5 9 * * * /bin/bash /www/wwwroot/cpacks/shell/run.sh > /dev/null 2>&1
#wq保存
#查看定时任务是否执行
tail -f /var/log/cron
Comment here is closed