Get the App
SLTechnology News&Howtos  ›  Servers  › 

SQUID Service (2) "script"

Shulou Source: shulou.com Published: 2022-06-03 00:54:22 09月23日 Update

"1"

In order to make SQUID services start, stop, restart and other operations more convenient, you can write SQUID service scripts and use CHKCONFIG and SERVICE tools to manage.

"2"

The script reads as follows:

#! / bin/bash

# chkconfig: 2345 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"

CONF= "/ etc/squid.conf"

CMD= "/ usr/local/squid/sbin/squid"

Case "$1" in

Start)

Netstat-anpt | grep squid & > / dev/null

If [$?-eq 0]

Then

Echo "squid is running"

Else

Echo "starting squid."

$CMD

Fi

Stop)

$CMD-k kill & > / dev/null

Rm-rf $PID & > / dev/null

Status)

[- f $PID] & > / dev/null

If [$?-eq 0]

Then

Netstat-anpt | grep squid

Else

Echo "Squid is not running"

Fi

Restart)

$0 stop & > / dev/null

Echo "shutting down squid."

$0 start & > / dev/null

Echo "starting squid."

Reload)

$CMD-k reconfigure

Check)

$CMD-k parse

*)

Echo "usage: $0 {start | stop | restart | check | status}"

Esac

# Press: wq save exit

"3"

Return to the terminal and do the following:

Chmod + x / etc/init.d/squid

Chkconfig-add squid

Chkconfig squid on

thus. You can use the SQUID script to start, stop, restart, and reload the SQUID server by adding the appropriate start,stop,restart,reload parameters during execution.

Tags: The script the service is in this way the content the parameter can be passed through the tool method is in the server terminal management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei MySQL OPPO Reno Xiaomi