Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
CRONTAB scheduling issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
durty_nacho
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jul 2004
Posts: 128
Location: Dallas

PostPosted: Thu Dec 06, 2007 1:49 am    Post subject: CRONTAB scheduling issue Reply with quote

Not sure where to post this, so I came here. Mods, if this is not the place, I apologize.

I have a cron job set to run every 3 minutes running blockhosts.py looking for dictionary attackers and blocking their IPs. This script has the capability of sending me an email each time it runs. Well, I don't want an email every 3 minutes, but I do want one every hour or so telling me its new additions to hosts.allow and iptables, etc. There is no way that I have found to make it only send you an email based on NEW additions (not even with --check-ip= "%h", I tried and tried), so the only way I can think to do this is make a second cron job to run the script with email commands inserted and run this one hourly.

The two end up running on top of each other on the hour, preventing one or the other from running (blockhosts.py prevents them from both running, not cron). Sometimes the email one runs and works while the other is told to stop, and sometimes the email one is the one stopped. Is there a way prevent scheduling issues? I tried placing the mail job above the rest, so that it runs first, but somehow I don't think crontab works like that. Any help would be great. Thanks in advance.
Back to top
View user's profile Send private message
OmSai
l33t
l33t


Joined: 30 Sep 2007
Posts: 605
Location: Manchester, CT, USA

PostPosted: Thu Dec 06, 2007 2:44 am    Post subject: Reply with quote

You're right, you should let your cron run two scripts.

Your first script runs for 3 minutes, which is perfectly divisible on the 60 minutes of an hour.
Just make sure to offset your second by one or two minutes :)

EDIT: Append the output of the py script with a preceding timestamp to a log file. Then parse the last timestamp to determine if sending an email is necessary
_________________
Gentoo is the stick-shift of Linux.
You work it manually, it has somewhat better performance, but it's really for the fun of it.
Back to top
View user's profile Send private message
durty_nacho
Tux's lil' helper
Tux's lil' helper


Joined: 22 Jul 2004
Posts: 128
Location: Dallas

PostPosted: Thu Dec 06, 2007 3:00 am    Post subject: Reply with quote

That gives me a great idea. I could run the hourly one every 59 minutes. Since the 3 minute one runs at 57 and then again on the hour, it should always miss :) You're a genious sir.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum