After testing, the script does not set up!!
The site uses a number of methods to accelerate (REDIS\CDN), this reduces user access to back-end MySQL pressure, as well as the front-end speed is not very good problem, the user requested to all the pages are cached, since the data cache, to solve the user saw the page is the latest page on the agenda, The following script is born. Hey...
Shell
#!/bin/bash
# Author:byrd
# version:0.1
# contact:root#t4x.org
# define Category
For category in Basic code database environment error Mobile Other project remark Route service switch system
Todo
For ((i=2;i<15;i++))
Todo
# Define return value
Return= ' Curl-o/dev/null-s-k-w "%{http_code}" https://www.111cn.net/$category/page/$i/?r=y '
If [$RETURN-eq 200]; Then
# If return value 200,then flush page and category.
Curl-o/dev/null-s-k-w "%{http_code}" https://www.111cn.net/$category/page/$i/?r=y >/dev/null 2>&1
Curl-o/dev/null-s-k-w "%{http_code}" https://www.111cn.net/$category/?r=y >/dev/null 2>&1
Else
# If return value is not 200,then flush category-A-page and site Page.break
Curl-o/dev/null-s-k-w "%{http_code}" https://www.111cn.net/$category/?r=y >/dev/null 2>&1
Curl-o/dev/null-s-k-w "%{http_code}" https://www.111cn.net/?r=y >/dev/null 2>&1
Break
Fi
Done
Done
The script is added to the scheduled task, because the site is not regularly updated, the update is not frequent, so every day to carry out the task.
[Root@site scripts]# echo ' #flush cache ' >>/var/spool/cron/root #注释
[Root@site scripts]# Echo 2 * * */bin/sh/byrd/scripts/flush_s ite.sh >/dev/null 2>&1 ' >>/var/spool/cron/root #两点执行计划任务
[Root@site scripts]# Crontab-l
#flush Cache
2 * * */bin/sh/byrd/scripts/flush_site.sh >/dev/null 2>&1