I have a script that has been running for several years. It's purpose is
to change the background image to a website randomly every minute.
This morning apache was not responding and the problem seemed to be that
this cron wasn't exiting, resulting in over 2000 processes running.
the output of ps looked like this:
root 381 0.0 0.0 2548 1028 ? S 04:50 0:00 CRON
root 382 0.0 0.0 1828 508 ? Ss 04:50 0:00 /bin/sh
-c run-parts --report /etc/cron.minute
root 383 0.0 0.0 1752 504 ? S 04:50 0:00
run-parts --report /etc/cron.minute
root 384 0.0 0.0 4196 1304 ? S 04:50 0:00
/bin/bash /etc/cron.minute/background
root 388 0.0 0.0 3480 764 ? D 04:50 0:00 cp
/var/www/html/sks.com/images/backgrounds/8.jpg
/var/www/html/sks.com/images/backgroundimage.jpg
this is the script, followed by the directory listing.
root@ns:~ # cat /etc/cron.minute/background
#!/bin/bash
# mv a random background pic for website
# images must be named 1.jpg 2.jpg ..... NUMFILES.jpg
DIR=/var/www/html/sks.com/images
NUMFILES=`ls $DIR/backgrounds/*.jpg | wc -l` # no. of images
let "i=($RANDOM%$NUMFILES)+1"
cp $DIR/backgrounds/$i.jpg $DIR/backgroundimage.jpg # cp to CSS location
root@ns:~ # ls /var/www/html/sks.com/images/backgrounds
10.jpg 11.jpg 12.jpg 13.jpg 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg
7.jpg 8.jpg 9.jpg
Even kill wouldn't work, so I had to hard reboot. After reboot the cron
script seems to be behaving itself again.
Can anyone suggest a reason for this behaviour?
--
David McQuire
0418 310312
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html