Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

To be a bit more concrete:

I have a Debian Squeeze Linux machine with a web application that should become available all over the planet. Until now I had a bunch of resource consuming cronjobs each night (in Europe) without much impact on regional user experience. However now I cannot afford that the server gets slower at any time.

Is there a way to force all cron scripts (cron.daily etc.) to inherit a nice and ionice priority?

Thanks for contributing!

Miguel

share|improve this question
add comment

3 Answers 3

You would probably best have these cron jobs run under a separate Linux user, which you can limit to lower priority. Let's say you have such a user batchuser. In your /etc/security/limits.conf, you would want to add an entry for this user (-19 to 19, with 19 being the lowest priority):

batchuser    -       priority        19

Then any processes started by this user, whether from cron or not, will inherit this priority. No modification to scripts, no env or profiles to set.

http://manpages.debian.org/cgi-bin/man.cgi?query=limits.conf

share|improve this answer
add comment

You may want to setting the crond service to run with nice and ionice already set.

http://b.zekjur.net/2012/09/23/systemd-ionice.html

However, I haven't tested that one, so I can't vouch for it one way or another.

If that doesn't work, or if it doesn't help enough, you'll need to configure cgroups.

share|improve this answer
add comment

Yes...

You could have the scripts source a particular set of environment variables or just run nice/ionice from within the script...

However, this is not a good resolution to your problem.

  • Can you offset or stagger the scripts so that they're not contending for resources?
  • Do you understand the timing or system activity patterns? E.g. Between 02:00 and 04:00, there are very few users on the system, and it's a good time to run maintenance scripts.
  • Do you have enough resources on your server?
  • nice and ionice aren't good long-term solutions. ionice, in fact doesn't have an effect on some of the more performance-based Linux kernel scheduling algorithms. It works with the CFQ scheduler, but chances are that you want to use the deadline scheduler on a server system. That may have a bigger impact than trying to force nice/ionice on the processes.
share|improve this answer
    
Thanks for your response. For me it's important that the scripts don't have to be modified individually as some of them are maintained by others. Therefore the nice and ionice priority should be kind of inherited from the parent cron? process. –  Miguel ZP Feb 17 '13 at 20:03
    
No way to inherit priorities? –  Miguel ZP Feb 20 '13 at 8:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.