[Lxc-users] Cron jobs in containers..

Gordon Henderson gordon at drogon.net
Thu Jul 8 19:30:06 UTC 2010


On Thu, 8 Jul 2010, Whit Blauvelt wrote:

> On Thu, Jul 08, 2010 at 06:46:20PM +0100, Gordon Henderson wrote:
>>
>> Sort of thinking out loud, but looking for suggestions/ideas ...
>>
>> So I have a host with 20 containers and each of these 'servers' runs cron
>> jobs - and one of them is to do an MRTG run every 5 minutes, so every 5
>> minutes, ka-chung, 20 jobs start at the same time which sort of has a bit
>> of a crowbarring effect...
>
> You could fudge it. For instance, I have two cron jobs that I want to run on
> alternate minutes. I give these as (in an /etc/cron.d file, thus the
> userid):
>
> */2 * * * * userid do_the_first_thing
> */2 * * * * userid sleep 60;do_the_second_thing
>
> There may well be an elegant way to do it, which this is not, but it does
> work to stagger jobs.

Hm. My situation is that I have:

*/5 * * * * root mrtg

inside every container, however exending that logic, I could do something 
like:

*/5 * * * root sleep `cat /etc/nodeDelay` ; mrtg

and I just keep /etc/nodeDelay to be 0, 10, 20, 30, 40, 50, etc. in each 
different container (10 seconds as mrtg is run every 5 seconds and I'm 
aiming for 20 containers per host for this application) I could probably 
be clever and do it by MAC address as each container has consecutive MAC 
addresses, but ...

However I've thought of something else - I'm running mrtg to get network 
traffic (for now - I want cpu cycles for each container later - if that's 
possible) so I could just run it on the host for each veth interface - 
however each one is created with a seemingly random name - is there any 
way to fix the name for each container?

Do the names change at boot time, or are they fixed at lxc-create time?

(Thats the trouble with thinking out loud, you go off on a tangent - or at 
least I do!)

Cheers,

Gordon




More information about the lxc-users mailing list