cPanel: How to monitor crond services using chkservd
When you are using cPanel cron services, you might found out the cPanel services down without any clue.
With this article, Mick Genie will guide you how to check your crond services by using cPanel chkservd services.
cPanel offer chkservd services to automatically monitor daemon services from the Linux server.
To done this, follow the step as below.
1. Open the file /etc/chkserv.d/crond, pico /etc/chkserv.d/crond
2. Add the command as below to the file.
service[crond]=x,x,x,/etc/init.d/crond restart,crond,root
3. Open the file /etc/chkserv.d/chkservd.conf, pico /etc/chkserv.d/chkservd.conf
4. Add command below to last line of the above file.
crond:1
5. Restart chkservd services, /scripts/restartsrv chkservd
cPanel MySQL database size show 0 MB
With WHM/cPanel 11.25, you might found out the MySQL database size show 0MB for all instead of the actual size of the database when you look from the MySQL section from cPanel.
To get this fix, you may easily change the cPanel config from SSH.
1. Log into the SSH.
2. modify the cpanel.config, pico /var/cpanel/cpanel.config.
3. Search for disk_usage_include_sqldbs=0.
4. Change to disk_usage_include_sqldbs=1.
5. Save it.
6. Compile the cPanel script, /scripts/update_db_cache.
Alternatively, log into the WHM, go to tweak setting and look for “When displaying disk usage in cpanel/WHM include Postgresql and MySQL.” and checked it.
Jailed Shell memory issue
If you are using Secure Shell (SSH), you might get these error when you running your php script.
PHP Fatal error: Out of memory (allocated 20447232) (tried to allocate 4096 bytes) in email.php
If you are the programmer or system administrator, you might tried to increase the memory_limit from the php.ini or using ini_set to increase the memory_limit but you will find out no matter how much memory_limit you set will not solve the problem.
The reason of the error occurs is not because of the PHP memory_limit usage of your script, but it is because the jailed shell limitation.
With cPanel jailed shell, the problem could caused by the forkbomb setting of your cPanel limited the PHP memory.
You may easily get this fix by modify the file as detail below where you should change the user to the cPanel user of your account.
/home/virtfs/user/etc/profile.d/limits.sh
Search for,
if [ "$LIMITUSER" != "root" ]; then
Then modify the ulimit “-m 200000″ to “-m unlimited” and save it.
Debugging Perl/CGI Scripts
By default, Perl/CGI script will send the error to STDERR where it is the server standard error and normally it will store to the server Apache error log.
To setup private error_log from your Perl/CGI script, you may easily get them done with script below.
BEGIN {
use CGI::Carp qw(carpout);
open(LOG, “>>/home/mickgenie.com/logs/cgi-error.log”) or
die(“Unable to open cgi-error.log: $!n”);
carpout(LOG);
}
The carpout() used to call the error and send it to the log file that you set.
To setup error to send to browser,
use CGI::Carp qw(fatalsToBrowser);
die “Couldn’t open log file”;
Use the above script and it could send all the error to the Browser.
Terminate cPanel account that suspended for more than 2 months
As a server administrator, you might want to follow-up which account has suspended for days and it’s the time for you to terminate it.
With a smart system administrator(lazy actually), you may have a custom script to check any of your account that been suspended for more than 2 months may terminate from the server automatically to save the resource/space from the server.
From this article, Mick Genie will guide you how to write a shell script and create it from the cronjob, however this step could only done by the root user.
1. Create a file name autoterminated_within60days.sh from /root/scripts/.
2. Insert the following code and save it.
for i in `find /var/cpanel/suspended/ -mtime +60 | cut -d’/’ -f5 | sed ‘1 d’`
do
y | /scripts/killacct $i;
done;
3. Create a cronjob, by typing crontab -e in SSH.
4. Type as following line in the crontab to apply daily checking.
0 0 * * * /bin/sh /root/scripts/autoterminated_within60days.sh



![[Google]]( http://linux.mickgenie.com/wp-content/plugins/easy-adsenser/google-light.gif)
