| 1 |
root |
1.1 |
#!/bin/sh |
| 2 |
|
|
# |
| 3 |
|
|
# thttpd-rotate - nightly script to rotate thttpd's log files on FreeBSD 3.x |
| 4 |
|
|
# |
| 5 |
|
|
# This goes in /etc/periodic/daily. It rotates the log files and then |
| 6 |
|
|
# tells thttpd to shutdown cleanly. The wrapper script will then start |
| 7 |
|
|
# up a new copy, writing to the new log file. |
| 8 |
|
|
|
| 9 |
|
|
cd /usr/local/www/logs |
| 10 |
|
|
rm -f thttpd_log.7 |
| 11 |
|
|
mv thttpd_log.6 thttpd_log.7 |
| 12 |
|
|
mv thttpd_log.5 thttpd_log.6 |
| 13 |
|
|
mv thttpd_log.4 thttpd_log.5 |
| 14 |
|
|
mv thttpd_log.3 thttpd_log.4 |
| 15 |
|
|
mv thttpd_log.2 thttpd_log.3 |
| 16 |
|
|
mv thttpd_log.1 thttpd_log.2 |
| 17 |
|
|
mv thttpd_log thttpd_log.1 |
| 18 |
|
|
pid1=`cat /var/run/thttpd.pid` |
| 19 |
|
|
kill -USR1 "$pid1" |
| 20 |
|
|
sleep 60 |
| 21 |
|
|
pid2=`cat /var/run/thttpd.pid` |
| 22 |
|
|
if [ "$pid2" -eq "$pid1" ] ; then |
| 23 |
|
|
kill -KILL "$pid1" |
| 24 |
|
|
fi |