| 段誉 回复于:2003-06-17 11:05:41
|
在启动之前,应该先停掉squid吧,有相同进程在跑,肯定不行啊。
|
| yeair 回复于:2003-06-17 11:30:42
|
进程我先用squid stop停掉了,也用pkill -u squid杀过,也reboot过,都一样呀,启动前ps -ef看过了,没有的。真的不知了,斑竹帮忙呀!!
|
| yeair 回复于:2003-06-17 13:14:26
|
up
|
| yeair 回复于:2003-06-17 21:49:47
|
问题终于解决了,原来我在squid.conf中加了
pid_filename /home2/var_squid/logs/squid.pid
本来,squid应该可以自己找到替换默认的,可是我打开
redhat 9的/etc/init.d/squid这个script才发现,它的默认居然是
/var/run/squid.pid
而且不能是别的,因为在下面的程序中有这样的判断:
[ ! -f /var/run/squid.pid ] || break
自然对于我的系统,永远都要break,所以failed是肯定的,虽然可以用,
但是pid号对于squid来说永远未知,所以stop也会failed,进程杀不死。
唉,居然这样~~~~~~我重新装了squid 2.5 stable3,那个脚本还是
老样子~~~~所以,只好动手了,现在把新改过的脚本贴出来,希望对大家有点用,不对地方还要多多指教!!!!
#!/bin/bash
# squid This shell script takes care of starting and stopping
# Squid Internet Object Cache
#
# chkconfig: - 90 25
# description: Squid - Internet Object Cache. Internet object caching is \
# a way to store requested Internet objects (i.e., data available \
# via the HTTP, FTP, and gopher protocols) on a system closer to the \
# requesting site than to the source. Web browsers can then use the \
# local Squid cache as a proxy HTTP server, reducing access time as \
# well as bandwidth consumption.
# pidfile: /var/run/squid.pid
# config: /etc/squid/squid.conf
########
#Update: 06172003, May & Chenzj, VLSI.ZJU,
# can set pidfile name in&s;'''/etc/squid/squidof'''
# like:&s;'''pid_filename /etc/run/squidi1'''
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# check if the squid conf file is present
[ -f /etc/squid/squid.conf ] || exit 0
if [ -f /etc/sysconfig/squid ]; then
. /etc/sysconfig/squid
fi
#&nbsdn'''t raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-"-D"}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
# determine the name of the squid binary
[ -f /usr/sbin/squid ] && SQUID=squid
[ -z "$SQUID" ] && exit 0
prog="$SQUID"
# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e&s;'''s/#/g''' /etc/squid/squid.conf | \
grep cache_dir | awkbp''''{ print $3&s;''''`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/spool/squid
# determine which one is the pidfile directory
PID_FILE=`sed -ebp''''s/*/'''' /etc/squid/squid.conf | \
grep pid_filename | awns;''''{ print $2bp}''''`
[ -z "$PID_FILE" ] && PID_FILE=/var/run/squid.pid
# echo $PID_FILE
RETVAL=0
start() {
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n "init_cache_dir $adir... "
$SQUID -z -F -D 2>/dev/null
fi
done
echo -n $"Starting $prog: "
$SQUID $SQUID_OPTS 2> /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f $PID_FILE ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n "."
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SQUID
[ $RETVAL -eq 0 ] && echo_success
[ $RETVAL -ne 0 ] && echo_failure
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$SQUID -k check >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
$SQUID -k shutdown &
rm -f /var/lock/subsys/$SQUID
timeout=0
while : ; do
[ -f $PID_FILE ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
echo
return 1
fi
sleep 2 && echo -n "."
timeout=$((timeout+2))
done
echo_success
echo
else
echo_failure
echo
fi
return $RETVAL
}
reload() {
$SQUID $SQUID_OPTS -k reconfigure
}
restart() {
stop
start
}
condrestart() {
[ -e /var/lock/subsys/squid ] && restart || :
}
rhstatus() {
status $SQUID
$SQUID -k check
}
probe() {
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
condrestart)
condrestart
;;
status)
rhstatus
;;
probe)
exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
exit 1
esac
exit $?
|
| yeair 回复于:2003-06-18 15:47:02
|
谢谢斑竹置顶:)
我再说详细一点:
主要修改的是一下部分:
# determine which one is the pidfile directory
PID_FILE=`sed -ns;''''s./g'''' /etc/squid/squid.conf | \
grep pid_filename | awns;''''{ print $2bp}''''`
[ -z "$PID_FILE" ] && PID_FILE=/var/run/squid.pid
用来得到PID_FILE的值,从squid.conf中。
然后就是相应的要把以前的/var/run/squid.pid 部分替换成
$PID_FILE,就这么简单:-)
|
| zzh2482 回复于:2003-11-13 03:55:10
|
请问我在使用redhat 9 自带的squid时,总是报一行错不知何意
请教!请教!
错误:FATAL:Could not determine fully qualified hostname
please sens;''''visible_htae''''
email:zhuzhenghua@126.com
|