How to monitor and auto restart cron service using cPanel chkservd?

Posted by admin     Category: cPanel Management

Sometimes the crond service fails quite often without any clue and it becomes necessary to monitor the cron service and auto-restart it. cPanel offers ‘chkservd’, a monitoring daemon that monitors the services on the server and restart them if found offline. cPanel/WHM do not provide an option to include the ‘crond’ service under the monitoring daemon, so following are the steps you can follow to achieve it:

Create a crond file under the chkservd.d directory where all the services files are placed:

# pico /etc/chkserv.d/crond

Add the following and save the file:

service[crond]=x,x,x,/etc/init.d/crond restart,crond,root

Now you need to edit the chkservd configuration file and enable the crond service for monitoring

# pico /etc/chkserv.d/chkservd.conf

add the following line at the end of the file

crond:1

Now, save the file and restart the chkservd service for the new changes to take affect:

# /scripts/restartsrv chkservd

In order to verify if chkservd auto-restarts the crond service if found offline, stop the service manually

# service crond stop

and watch the logs

# tail -f /var/log/chkservd.log

You will notice that the crond service is restarted automatically within 5 minutes.

cpanel: mysql database size 0MB

Posted by admin     Category: cPanel Management

You may see the mysql database size as zero in cPanel >> ‘Mysql Databases’ option, though the databases contains tables and data. In order to include the size of the databases while displaying disk usage in cPanel/WHM, perform either of the following steps:
1) SSH to your server as root and edit the cpanel.config file

# pico /var/cpanel/cpanel.config

Search for

disk_usage_include_sqldbs=0

and change to

disk_usage_include_sqldbs=1

If the parameter is not present, add it. Save the file and execute the following command:

# /scripts/update_db_cache

OR

2) Login to the WHM, goto Tweak Settings >> ‘SQL’ section and enable the following option:

When displaying disk usage in cpanel/WHM include Postgresql and MySQL.

This will fix the issue.

qmail-inject: fatal: mail server permanently rejected message

Posted by admin     Category: Plesk Management

You see the “qmail-inject: fatal: mail server permanently rejected message” error message while sending emails from a Plesk server and the error message such as follows in the mail logs:

qmail-queue-handlers[xxxx]: Unable to change group ID: Operation not permitted
qmail-queue[xxxx]: files: write buf 0xbff4dfe0[156] to fd (5) error – (32) Broken pipe
qmail-queue[xxxx]: files: cannot write chuck from 4 to 5 – (32) Broken pipe

It is due to the incorrect permission/ownership of the ‘qmail-queue’ file under the “/var/qmail/bin” directory. Make sure
the ownership is ”mhandlers-user:popuser’
the permission is 2511.

Check the current ownership/permission:

# ls -la /var/qmail/bin/qmail-queue

It should be as follows:

-r-x–s–x  1 mhandlers-user popuser 67804 May  4 08:41 /var/qmail/bin/qmail-queue

If not, correct the ownership

# chown mhandlers-user.popuser /var/qmail/bin/qmail-queue

set the proper permissions,

# chmod 2511 /var/qmail/bin/qmail-queue

Restart Qmail once and see if the email works.

Note: If the emails still doesn’t work, please comment this post with the error message and the output of the following command and I will find out the solution for you:

ls -la /var/qmail/bin/qmail-queue*

vzquota : (error) Quota on syscall for xxx: Device or resource busy

Posted by admin     Category: VPS Management

You may receive the following error message while starting a VPS:

root@server [~]# vzctl start VEID
vzquota : (error) Quota on syscall for id xxx: Device or resource busy
vzquota : (error)       Possible reasons:
vzquota : (error)       – Container’s root is already mounted
vzquota : (error)       – there are opened files inside Container’s private area
vzquota : (error)       – your current working directory is inside Container’s private area
vzquota : (error)       Use -v option to see currently opened file(s).
Running vzquota on failed for Container xxx

The error message indicates 2 things:

1) There are some files in open state inside the VPS private area. You can check if there are any open files by executing:

lsof 2> /dev/null | egrep ‘/vz/root/xxx|/vz/private/xxx’

where, xxx is the VPS ID. It will list the open files which you can close and start the VPS.

2) Your current working directory on the host server is inside the VPS’s private area i.e. the private area of the VPS is at /vz/private/xxx and your current working directory while starting the VPS is inside /vz/private/xxx.

Check the current working directory:

root@server [~]# pwd

if the working directory is inside the VPS’s private area, come out of that directory by just executing the command

root@server [~]#  cd

This will bring you out to the home directory of the root user and you will be able to start the VPS without any issues.

root@server [~]# vzctl start VEID

Error: Unable to execute bash: No such file or directory

Posted by admin     Category: VPS Management

You may receive “Unable to execute bash: No such file or directory” error message while starting a VPS and the result is the VPS fails to start. The reason is, either the binaries from /bin OR /usr/bin are missing OR corrupted.

To fix the issue, you either copy the directories /bin and /usr/bin from a working VPS OR from the OS template the VPS is using.

Solution:

1) Copy directories from a working VPS:

cp -p /vz/private/VEID1/fs/root/bin /vz/private/VEID/fs/root/ -R
cp -p /vz/private/VEID1/fs/root/usr/bin /vz/private/VEID/fs/root/usr/ -R

where,

VEID1 is the working VPS
VEID is the VPS in question

2) Copy directories from the OS template. The OS templates are stored under /vz/template/cache directory.

a) Extract the template file the VPS is using

cd /vz/template/cache/
tar -zxf os-templatename.tar.gz

b) Copy the directories to the VPS private area

cp -p /vz/template/cache/root/bin /vz/private/VEID/fs/root/ -R
cp -p /vz/template/cache/root/usr/bin /vz/private/VEID/fs/root/usr/ -R

Once copied, make sure you are out of the VPS private area and restart the VPS.

vzctl start VEID

It will re-calculate the quota of the VPS and will start the VPS.