[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [BAD] the whole server down with a red-alert-like attack



On Fri, Jan 25, 2002 at 10:28:56AM +1100, Russell Coker wrote:

> IMHO something that runs every minute should not be in cron, even something 
> that runs every 5 minutes possibly shouldn't be in cron.

:) s/should not/must not/ if I do't want problems
Yeah, I made a painful experience myself.

> A shell script that does the following should do:
> #!/bin/sh
> 
> while /bin/true ; do
>   /usr/local/bin/something
>   sleep 60
> done

The problem with this code is that the cycle is slightly greater then
60 seconds.  This desynchronize the script very early.

As I remember I quick hack my problem with test if a previous run was
done.  If not, I simply skip this one.

> So if the script takes hardly any time to run then it runs every minute.  If 
> it takes a lot of resources then it'll run only one copy at a time, and have 
> a 1 minute break between runs (time for other programs to get some CPU time 
> etc).
> 
> What would be handy would be to have a program that did all this, so I could 
> do:
> 
> /usr/bin/runevery 60seconds /usr/local/bin/something
> To get the same result as the above shell script.

or as I wrote above, something like:
#!/bin/sh
if previous instance is stil running; then
	report time presure
	exit
fi
do some usefula data gathering and/or processing


> Then for even more protection it could have options to monitor and/or limit 
> CPU usage and log to syslog.
> 
> Does this sound good?  If I get a dozen people sending me private email 
> stating that they want to use such a program then I'll write it and add it to
> my logtools package.

hmm.  doesn't such program exist yet?

Main usage for such a program/tool is (from my point of view) data
gathering on routers.  Someting like an ipac tool does.  But sometimes
man needs to made its own data gathering scripts.


Yes, there are many tools for such a case, but I always love small
simple nice handmade scripts.


Sorry for my english.  I'm not sure with some words like desynchronize.
-- 
Radek Hnilica <Radek at Hnilica dot CZ>
===========================
No matter how far down the wrong road you've gone, turn back.
						Turkish proverb





Reply to: