LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash scripts which go bump in the night and the system resources who hate them (https://www.linuxquestions.org/questions/programming-9/bash-scripts-which-go-bump-in-the-night-and-the-system-resources-who-hate-them-202216/)

dehuszar 07-08-2004 02:19 PM

Pretty 'effing cool if you ask me. I will go over this later in the week with a fine toothed comb (i.e. my bash book) and make a little more sense of it and see if I come up with anything. Thanks for putting such time into it.

Thanks again.

Sam

p.s. I feel your pain. Being a problem solving wizard gets one drawn into all kinds of madness... ;) . I truly appreciate it though.

Dark_Helmet 07-08-2004 03:24 PM

No problem. If anything isn't clear, just holler.

I did edit it a little though; minor stuff that doesn't affect operation.

I would have thrown in a "cleanup" mode, but the way the script works, there's very little chance (if any) that it would become zombied. If it does, then there's probably a bigger problem than email to worry about. If you'd like to add a cleanup-type of option to the script (as a tinkering exercise or if it becomes necessary), then I'd follow keefaz's lead: something simple like echoing the pid of the script to a file and then removing it on successful completion of the script.

And I forgot to mention, the cron entries were just arbitrarily picked by me. If you wanted to maintain the once per two minutes routine, you could change them to:
Code:

0-58/2 * * * * /path/to/script local
1-59/2 * * * * /path/to/script external

That'll do the same thing as previously: stagger the scripts so only one runs at a time. "local" executes on every even minute of the hour, and "external" executes on every odd minute of the hour. If the format is a little unclear, here's the Cliff's Notes version (man 5 crontab for gory details):

first field: minute
all other field: hour, day of month, month, day of week

if given a range, (such as 1-5) then the command is executed on every matching field within the range (i.e. at minute 1, 2, 3, 4, and 5)

If given a range followed by a slash, the number after the slash gives the "step" amount.

An asterisk means match any value


All times are GMT -5. The time now is 05:57 PM.