#!/bin/bash
# chkconfig: - 90 25 #其中-的意思是所有运行级别
# config: /etc/squid.conf
# pidfile: /usr/local/squid/var/run/squid.pid
# Description: Squid - Internet Object Cache PID="/usr/local/squid/var/run/squid.pid" #程序运行才会有pid文件,反之则无
CONF="/etc/squid.conf"
CMD="/usr/local/squid/sbin/squid" case "$1" in
start)
netstat -utpln | grep squid $> /dev/null
if [ $? -eq 0 ]
then
echo "Squid is running"
else
$CMD
fi
;;
stop)
$CMD -k kill $> /dev/null #调用squid命令停止服务
rm -rf $PID $> /dev/null #删除pid文件
;;
status)
[ -f $PID ] &> /dev/null #检测pid文件是否存在
if [ $? -eq 0 ] #假如文件存在则0等于0,执行netstat命令展示端口
then
netstat -utpln | grep squid
else
echo "Squdi is not running"
fi
;;
restart)
$0 stop $> /dev/null #注意:$0 stop的意思是调用之前定义的stop
echo "正在关闭Squid..."
$0 start $> /dev/null
echo "正在启动Squid..."
;;
reload)
$CMD -k reconfigure #重新加载,但不中断服务,配置更改后,建议用这种方式加载
;;
check)
$CMD -k parse #检查配置文件语法是否错误
;;
*)
echo "$0的用法:{start | stop | restart | reload | check | status}" # $0代表脚本名字/etc/squid.conf的用法
;;
esac

Squid系统服务脚本的更多相关文章

  1. linux 拨号+squid监控脚本

    客户端 #!/bin/bash #get_memory-info a=`free -m|grep Mem|awk '{print$2}'` #total-memory b=`free -m|grep ...

  2. Centos6优化系统服务脚本

    #!/bin/bash SysVer=`cat /etc/redhat-release | awk -F'release' '{print $2}' | awk -F'[ .]+' '{print $ ...

  3. Squid代理服务器

    缓存代理概述:做为应用层的代理服务软件,squid主要提供缓存加速,应用层过滤控制的功能. 1.代理的工作机制 当客户机通过代理来请求web页面时,指定的代理服务器会先检查自己的缓存,如果缓存中已经有 ...

  4. CentOS 7 搭建Squid代理服务器

    Squid安装 官方地址:http://www.squid-cache.org/ [root@DaMoWang ~]# -r6d8f397.tar.gz [root@DaMoWang ~]# -r6d ...

  5. 构建squid代理服务器

    基本概念 本文使用squid代理服务 软件介绍:百度百科 作为应用层的代理服务软件,Squid主要提供缓存加速.应用层过滤控制的功能: 工作机制:缓存网页对象,减少重复请求(HTTP代理的缓存加速对象 ...

  6. CentOS 7.x设置自定义开机启动,添加自定义系统服务

    Centos 系统服务脚本目录: /usr/lib/systemd/ 有系统(system)和用户(user)之分, 如需要开机没有登陆情况下就能运行的程序,存在系统服务(system)里,即: /l ...

  7. squid 学习笔记

    Squid学习笔记 1.安装前的配置 编译安装之前需要校正的参数主要包括File Descriptor和Mbuf Clusters. 1.File Descriptor 查看文件描述符的限制数目: u ...

  8. 编写shell管理脚本(一)

    7.1  查看当前linux系统中能够使用的shell程序的列表[root@localhost ~]# cat /etc/shells/bin/sh/bin/bash/sbin/nologin/bin ...

  9. 制作service服务,shell脚本小例子(来自网络)

    事先准备工作:源码安装apache .安装目录为/usr/local/httpd 任务需求:1.可通过 service httpd start|stop|status|restart 命令对服务进行控 ...

随机推荐

  1. Python时间日期函数讲解

    所有日期.时间的api都在datetime模块内. 1. 日期输出格式化 datetime => string import datetime now = datetime.datetime.n ...

  2. 让你的javascript代码高大上

    1,创造简短的写法 你可以这么写: var slice = Array.prototype.slice; slice.call(arguments); //转化成数组 也可以这么写:(ie9+) va ...

  3. leetcode804

    int uniqueMorseRepresentations(vector<string>& words) { map<char, string> st; st.ins ...

  4. Mycat基本搭建

    1.Java环境检查与安装(略) [检查] [root@mysqldb tmp]# java -verson -bash: java: command not found [直接解压安装] [root ...

  5. 浅谈PL/SQL语言基础

    在前面的学习中,我们大部分接触的都是SQL语言,但是,在实现复杂操作的时候,SQL语言就无能为力了,这时候就需要引入新的语言,PL/SQL语言就是对SQL语言的扩展,可以实现存储过程,函数等的创建.下 ...

  6. 599. Minimum Index Sum of Two Lists两个餐厅列表的索引和最小

    [抄题]: Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of fa ...

  7. 566. Reshape the Matrix矩阵重排

    [抄题]: In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a ...

  8. 基于 EntityFramework 的数据库主从读写分离架构(1) - 原理概述和基本功能实现

        回到目录,完整代码请查看(https://github.com/cjw0511/NDF.Infrastructure)中的目录:      src\ NDF.Data.EntityFramew ...

  9. php抓取网页中的内容

    以下就是几种常用的用php抓取网页中的内容的方法.1.file_get_contentsPHP代码代码如下:>>>>>>>>>>>&g ...

  10. 编写高质量代码改善C#程序的157个建议——建议29:区别LINQ查询中的IEnumerable<T>和IQueryable<T>

    建议29:区别LINQ查询中的IEnumerable<T>和IQueryable<T> LINQ查询一共提供了两类扩展方法,在System.Linq命名空间下,有两个静态类:E ...