File: 500.thttpd-rotate

package info (click to toggle)
thttpd 2.23beta1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 684 kB
  • ctags: 679
  • sloc: ansic: 7,908; sh: 1,871; makefile: 310
file content (24 lines) | stat: -rwxr-xr-x 670 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
#
# thttpd-rotate - nightly script to rotate thttpd's log files on FreeBSD
#
# This goes in /etc/periodic/daily.  It rotates the log files and then
# tells thttpd to shutdown cleanly.  The wrapper script will then start
# up a new copy, writing to the new log file.

cd /usr/local/www/logs
rm -f thttpd_log.7
mv thttpd_log.6 thttpd_log.7
mv thttpd_log.5 thttpd_log.6
mv thttpd_log.4 thttpd_log.5
mv thttpd_log.3 thttpd_log.4
mv thttpd_log.2 thttpd_log.3
mv thttpd_log.1 thttpd_log.2
mv thttpd_log thttpd_log.1
pid1=`cat /var/run/thttpd.pid`
kill -USR1 "$pid1"
sleep 60
pid2=`cat /var/run/thttpd.pid`
if [ "$pid2" -eq "$pid1" ] ; then
    kill -KILL "$pid1"
fi