Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automate Hotline news file rotations Apps
One of the most dreaded things when running a Hotline server is cleaning the news. I wrote the following script to automate that task. Most of it is set up as variables that can easily be changed for your set up. I have only tested it with the hxd server, however it should also work with a plain vanilla Hotline server. For adding it to cron, I suggest grabbing CronniX for easy editing.

Read the rest of the article for the script...

#! /bin/sh

###########################################
# Hotline News Cleaner v1 by James Huston #
# Add this program to the cron system to #
# auto clean your news file at specified #
# times. #
###########################################

# CHANGE THESE VARIABLES FOR USE ON YOUR SYSTEM #
hxdpath=/Users/hxd/ #path to the hxd server root
newssize=30000 #size to act upon in bytes
posts=3 #number of posts you want to keep
newsdelim="_________________________________________________" # the news delimiter
tdate=`date +%x | tr "/" "-"` #date formate for arcived files

cd "$hxdpath" #change to server folder
cursize=`ls -l news | tr -s " " "\t" | cut -f 5` #get news file size in bytes
if [ $cursize -gt $newssize ] #test the size
then
cp news news$tdate.txt #backup current news file
#run an awk program passing the number of posts to keep
#print each line from the top
#if the line is the delimiter increase counter by one
#if the counter equals the keep value exit
awk -v keep=$posts -v delmi=$newsdelim '{ print $0;
if ($0 == delim) counter = counter + 1;
if (counter == keep) exit }' news$tdate.txt >> news.new
gzip -9 news$tdate.txt #archive the old news file
mv news.new news #mv the new news file replacing the old
fi
Save the script, make it executable (chmod 755 script_name), and make sure it's stored somewhere on your path.
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[2,559 views]  

Automate Hotline news file rotations | 1 comments | Create New Account
Click here to return to the 'Automate Hotline news file rotations' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Re: Cleaning Hotline News...
Authored by: bigdog on Jun 18, '02 01:15:57PM

The only way this would work with a plain vanilla Hotline server is if you had a OneClick or Quickkeys script that would press your 'Reload News' button or if you had said cron script kill the server app and re-launch it.

also, dental.



[ Reply to This | # ]