View previous topic :: View next topic |
Author |
Message |
durty_nacho Tux's lil' helper
Joined: 22 Jul 2004 Posts: 128 Location: Dallas
|
Posted: Thu Dec 06, 2007 1:49 am Post subject: CRONTAB scheduling issue |
|
|
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 |
|
|
OmSai l33t
Joined: 30 Sep 2007 Posts: 605 Location: Manchester, CT, USA
|
Posted: Thu Dec 06, 2007 2:44 am Post subject: |
|
|
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 |
|
|
durty_nacho Tux's lil' helper
Joined: 22 Jul 2004 Posts: 128 Location: Dallas
|
Posted: Thu Dec 06, 2007 3:00 am Post subject: |
|
|
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 |
|
|
|
|
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
|
|