High cpu load during the night..

Duboux

Verified User
Joined
Apr 20, 2007
Messages
244
I noticed a high serverload (80%) during the night..

I bet it is some cron job..
But I can't find a way to see all the cronjobs that are on that server..

What is a bit disturbing is that this high load takes over an hour.

The box has a dual core 2x2.80GHz and 1gb of ram.

How can I see allll the cronjobs in 1 view ?
 

Attachments

  • cpu.jpg
    cpu.jpg
    44.3 KB · Views: 204
Do you have a scheduled backup? That's the most obvious possibility.

Jeff
 
I don't know how to see all the cronjobs, but when I type:
Code:
# crontab -l
# backup
0 1 * * * /*****/backup.scp
# Copy yesterdays exim reject logs to a database
0 2 * * * /*****/cron_eximreject_2_db.sh
There's a backup proces alright, but it's at 1 am, not at 5.

How can I find other cronjobs ?

Code:
# ls -l /etc/cron.daily
total 68
lrwxrwxrwx  1 root root   28 Mar  3 17:05 00-logwatch -> ../log.d/scripts/logwatch.pl
-rwxr-xr-x  1 root root  418 Nov 19  2004 00-makewhatis.cron
-rwxr-xr-x  1 root root  276 Sep 28  2004 0anacron
-rwxr-xr-x  1 root root 2133 Nov 23  2004 prelink
-rwxr-xr-x  1 root root  104 Nov  2  2004 rpm
-rwxr-xr-x  1 root root   82 Aug 10  2005 slocate.cron
-rwxr-xr-x  1 root root   58 May 20 18:00 tijd [COLOR="Red"]<-- I made this one, to update the time and date[/COLOR]
-rwxr-xr-x  1 root root  286 Aug 14  2004 tmpwatch
-rwxr-xr-x  1 root root  136 Jul  5  2005 yum.cron
 
Last edited:
I don't know what your backup.scp job is. I don't have one. I have a copy of sysbk running in my root user cronjob. sysbk can add a lot of serverload; perhaps your backup.scp job does, too.

What time does your system run the jobs in /etc/cron.daily (you can find that out by looking into /etc/crontab).
Code:
$ crontab -l
is a look into the current user's crontab. You can run it for other users this way, but only as root. For example:
Code:
# crontab -l -u admin
for the admin user, and for other users as well. But that won't tell you which users have crontabs.

The list of users with crontabs is in /var/spool/cron. Look for non-zero-length files. You can just use an editor (or the less command) to look through the cronjobs in /var/spool/cron. But don't make changes to these files manually; instead edit them with the crontab command:
Code:
# crontab -e -u admin
The above will let you edit the crontab for admin using the VIM editor, or alternatively whatever editor is set in your EDITOR environment variable.

Have I managed to be even more confusing ;) ?

Jeff
 
Thanx for the help :)

The crontab -l (or -e) command showed the 2 cronjobs I posted above (the backup and the eximthing)
there's no cronjob on admin, since there's no admin account on that server. (well there is, but no domain/useraccount)

Code:
# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
This 4am daily cron probably explains the little spike in the cpu-load-image, posted earlier

Code:
# ls /var/spool/cron
diradmin  user1 user2  root  user3

I found a cronjob that starts around 5am..
Code:
# crontab -l -u diradmin
5 5 * * *  echo -e "action=backup&id=1&owner=admin" >> /usr/local/directadmin/data/task.queue.da; /bin/chmod 600 /usr/local/directadmin/data/task.queue.da

So this is a backup ?
 
Last edited:
It looks like a backup.

Since it appears to be an admin backup you should look at all backup possibilities in the admin level of the control panel.

Jeff
 
If you have root access, create this script as readcrontab.sh

Code:
#!/bin/sh

myemail=$1
if [ -n "$myemail" ] ; then
        mycrontmp=/root/cron.tmp.$$
        # get current user list
        for i in `cat /etc/passwd | cut -f1 -d ':' | grep -v '#'`; do
                echo "--------------------------------------------------"
                echo "Username: ${i}"
                echo "--------------------------------------------------"
                crontab -u ${i} -l 2>&1
                echo "--------------------------------------------------"
        done > $mycrontmp
        cat $mycrontmp | mail -s "crontab report for `hostname`" ${myemail}
        rm -f $mycrontmp
else
        echo "Please supply a valid email address to get the report."
        exit
fi

chmod 755 readcrontab.sh

then ./readcrontab.sh [email protected]

it'll send an email of ALL user crons on the server
 
Nice script, Joe.

Coincidentally we had the same problem with a system last night; it appears to be caused by the sysbk backing up a huge site. I don't know why that would do it, unless the nice level set in conf.sysbk isn't working, but that's what it looked like to us.

Jeff
 
Back
Top