[Users] [PATCH] Reduce Load in VZs - stop cron.d thundering herd...

Tim Small tim at seoss.co.uk
Wed Aug 3 04:29:32 EDT 2011


On 03/08/11 08:47, Kir Kolyshkin wrote:
>
> (3) CT has a distro installed which has crontab in some unusual location

Nearly (3)

/etc/cron.d is a standard location, but vps-postcreate.sh didn't deal
with it.

I thought I'd submitted this patch to debian, but I seem to have dropped
it :-(

Tim.

--- postcreate.sh.old   2010-09-14 06:07:31.000000000 +0100
+++ /etc/vz/dists/scripts/postcreate.sh 2011-08-03 09:27:22.490356610 +0100
@@ -24,12 +24,12 @@
 
 function randcrontab()
 {
-       file=${VE_ROOT}"/etc/crontab"
+       for file in ${VE_ROOT}/etc/cron.d/* ${VE_ROOT}/etc/crontab
+       do
+               [ -f "${file}" ] || return 0
 
-       [ -f "${file}" ] || return 0
-
-       /bin/cp -fp ${file} ${file}.$$
-       cat ${file} | awk '
+               /bin/cp -fp ${file} ${file}.$$
+               cat ${file} | awk '
 BEGIN { srand(); }
 {
        if ($0 ~ /^[ \t]*#/ || $0 ~ /^[ \t]+*$/) {
@@ -61,8 +61,9 @@
        }
        print line;
 }
-' > ${file}.$$ && /bin/mv -f ${file}.$$ ${file}
-       /bin/rm -f ${file}.$$ 2>/dev/null
+               ' > ${file}.$$ && /bin/mv -f ${file}.$$ ${file}
+               /bin/rm -f ${file}.$$ 2>/dev/null
+       done
 }
 
 function disableroot()





-- 
South East Open Source Solutions Limited
Registered in England and Wales with company number 06134732.  
Registered Office: 2 Powell Gardens, Redhill, Surrey, RH1 1TQ
VAT number: 900 6633 53  http://seoss.co.uk/ +44-(0)1273-808309



More information about the Users mailing list