Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I maintain a large MRTG system (~30k graphs) and would like a way to stagger cron jobs that run every five minutes. I am guessing there is some way of doing this using a range such as 2-59/5 in the minutes field, but i have been unsuccessful. The thinking behind this is that i can stagger the cron jobs...one start exactly every 5 minutes and have the next ones started on the sixth minute and run for five minutes, etc.
If anyone has any guidance, it would be greatly appreciated.
With a launcher script you can do all sorts of pre-running checks For example you could check for the existence of previous instances of a program before running, and only launch if there are not already multiple instances on the go (pgrep is your friend). Or you could run only if the load average is lower than some level.
Last edited by matthewg42; 07-03-2008 at 04:08 PM.
He's not talking about running cronjobs every 5 minutes.
He is talking about say if he has 10 cronjobs, to:
- start the first one at 0, then again every 5 minutes
- start the second one at 1, then again every 5 minutes
- start the third one at 2, then again every 5 minutes
And so forth.
matthewg24 has it nailed pretty much...just kick off a script that spawns the correct job each minute...great use of the modulo operator
A much better way is to introduce a "batch scheduler." There are a great many of these for Linux that are open-source.
The essential idea is that now you are able to define jobs, in such a way that the batch scheduler can decide how to run them on the various computers in your network. You no longer have to specify exactly which computer(s) will run the job (except to the degree that you need to...), and you no longer have to try to laboriously specify exactly when. Instead, you give the batch scheduler enough information to allow it to make those decisions dynamically, in response to actual workload.
Generally speaking, a batch scheduler will include at least three major subsystems:
The scheduler(s) observe the "to-do list" and decide what a particular computer should do next.
Each computer has a job monitor that observes and reports exactly what a particular job is doing. The job monitor has the power to kill the job, to suspend it and so-on.
Output disposition and file staging mechanisms get the output to a common place, and arrange for the files needed by a job to be within reach of that job when it runs.
They can also have neat features like these:
Suspend/Resume: a job can be suspended and can then resume where it left off.
Checkpoint/Restart: a job that fails does not have to start over.
Multi-process/Multi-worker jobs: a job that can run across multiple processes and/or processors to the extent that the job scheduler determines that such resources are available.
When you "set up complicated crontabs," you're basically having to guess. If you guess wrong and set the times too short, jobs run into one another. Too long, and you're wasting precious milliseconds. A batch scheduler is a much smarter solution.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.