WHAT'S NEW?
Loading...

Have you ever noticed that your scheduled posts in WordPress are missing? Though WordPress has its own cron feature that dictates the scheduling of your blog's posts and events, WP-cron is not a literal cron job.

Linux Cron Job vs. WP-Cron

Linux cron jobs can be controlled by the user, making certain that the items constrained by schedule are run appropriately. Also, for a high-traffic WordPress site, a Linux cron job can assist with reducing the chances of downtime by lowering the bandwidth on the server, thus using less server resources.
WP-cron is a virtual cron that only works when the page is loaded. WP-cron is first loaded by WordPress when a page is requested on the front or backend of a site at which point WP-cron displays the necessary page to the site visitor. Though convenient, it is known to fail for a variety of reasons, including but not limited to the following:
  • Conflict of plugins
  • DNS-related issues
  • WordPress bugs
  • Use of caching plugins
  • Large server load

How to Replace WP-Cron With a Linux Cron Job

The best way to optimize the efficiency of your WordPress cron jobs is to disable WP-cron and set up a normal cron job through cPanel which will run every hour.

1. Disable wp-cron.php

You can disable WP-cron by modifying the wp-config.php (located in the folder where WordPress is installed). Open the wp-config.php file, add a new line after <?php, then add the following code on the new line:
define('DISABLE_WP_CRON', true);

2. Set Up a Linux Cron

Warning: It is important that you familiarize yourself with how cron jobs work. You need to have a working knowledge of Linux commands before you can use cron jobs effectively.
To set up a Linux cron job:
  1. Log into your cPanel.
  2. In the Advanced section, click Cron jobs.
  3. Under Add New Cron Job, select the time interval. HostGator recommends that you do not set the interval lower than 15 minutes.
  4. Set the cron command to the following, replacing yourwebsite.com with your actual domain name:
    wget -q -O - http://yourwebsite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
    The above command tells the Linux server to run wp-cron via wget, which will trigger the wp-cron.php script to do it's job on your schedule instead of on each page view. 
  5. Click Add New Cron Job to set the cron.
In order to test out the new cron, simply wait for the elapsed time period for the cron to run. In the event that the cron does not run, please review the steps listed above to ensure that you have completed all steps correctly.

Staggering Multiple WordPress Cron Jobs

Creating cron jobs for multiple WordPress crons without custom configuration can cause them all to fire at the same time. Having multiple cron jobs run at the same time can cause your CPU usage to increase, negating the benefit of using Linux cron jobs. To stagger your cron jobs:
  1. Divide 60 by the number of WordPress installations you have. If you have more than 60, simply use the number 1.
    Example: If you have 6 WordPress installations, 60 divided by 6 equals 10.
  2. When creating your wordpress cron jobs, use 0 for minutes for your first cron job.
  3. For each cron job after the first one, add the number you got in step 1.
    Note: If you have more than 60 WordPress sites, after you reach 59 you will need to start at 0 again. If you experience CPU issues with this many WordPress sites running cron jobs this frequently, you may wish to consider migrating some of your sites to a second account.
By following these steps you will ensure that your WordPress cron jobs run once per hour and that there is as little overlap as possible between them, which should greatly improve your CPU usage with this platform.
Wordpress is an amazing CMS or Content Management System that makes creating and maintaining a website really easy. However at times it can cause high resource usage when not optimized properly.

Why you should optimize WordPress

Because WordPress makes it so easy to do a lot of things, this requires a lot of stuff going on in the background. Depending on the size and complexity of your website, as well as the traffic you receive, you'll want to pay extra close attention to making sure your WordPress site is optimized to handle the type of traffic you get.
If you've viewed your account's resource usage with the CPU graphs available in cPanel, and noticed your account has been going outside of your alloted usage, or if you've been contacted about your usage by our systems administration team, now is a great time to make sure WordPress isn't the culprit of your usage.

Steps to ensure an optimized WordPress setup

Below I've compiled a list on what we recommend doing to optimize your WordPress website.
These are ordered by the typical resource usage reduction expected from each method, and not all are required.
For instance most customers just need WordPress caching and that's enough to bring the resource usage down.

  1. Implement WordPress caching

    WordPress by default will dynamically create your pages and posts by pulling from your database.
    If you have 100 people view one of your pages, by default this will cause 100 PHP executions.
    Instead the first person to view your page should pull from the database, and create a cached page.
    This cached page can be viewed, hundreds, if not thousands of times by others with minimal usage.
    WP Super Cache (Basic and easy to setup)
    W3 Total Cache (Offers more advanced caching options)
  2. Be careful of known intensive WordPress plugins

    WordPress plugins can vary greatly in how efficiently they were created, since anyone can make one.
    You can try to find an alternative plugin, seeing if leaving one of these disabled brings your resource usage down enough, or if it's really necessary to your site's function you could upgrade to a VPS.
    You could also use the P3 Plugin Performance Plugin to try to figure out which WordPress plugins are the most intensive.
    Below is a list of plugins we've seen customers have issues with before as they seem to utilize a large amount of resource usage compared to most plugins.
    CMS Tree Page ViewConstant Contact WordPress WidgetDigi Auto Links
    Disqus Comment SystemFireStats WordPressGeo Mashup
    Google Talk WidgetNextGEN GalleryPHP Code for Posts
    Quotes CollectionReveal IDsSimple Post Thumbnails
    Skype StatusVaultPressWassUp Real Time Analytics
    WordgentowpCloakerWordPress Facebook
    WP Forum ServerWP Live StreamOnline Backup for WordPress
    WP Autoresponder and News PluginWP Super HeatmapWP Symposium
    Yet Another Related Posts Plugin
  3. Disable default wp-cron.php behaviour

    WordPress runs wp-cron.php on every visit to basically ask "do I have anything to do?"
    When visitors start to roll in, checking multiple times the same hour is very inefficient.
    By default your wp-cron.php script could be getting called hundreds of times an hour.
    Setup a manual cron job to run this instead, at a more appropriate 4 or 6 hour interval.
  4. Disable WordPress autosave and log out of dashboard

    WordPress autosaves, and admin dashboard activity goes to the /wp-admin/admin-ajax.php script.
    There can sometimes be hundreds, if not thousands of these requests and you can limit them by disabling the autosave feature in WordPress and staying logged out of the admin when not in use.
  5. Limit or block search engine crawlers

    By using a robots.txt rules file, you can deny access to certain search engines you don't want crawling your website, or deny them to particular sections of your website.
  6. Block unwanted users from your site

    You can outright deny access to your website from either certain IP addresses, or User-Agents.
    For instance the following .htaccess code would block the Chinese Baidu.com spider, HTTrack which is a website copier, and the Russian Yandex.com search engine.
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex).*$ [NC]
    RewriteRule .* - [R=403,L]
  7. Deal with WordPress comment spam

    You should be using a CAPTCHA plugin to protect against comment spam like WP-reCAPTCHA.
    If your WordPress site already has comment spam you can clean up WordPress comment spam.

    Find out who is comment spamming you

    If you alread have comment spam you should remove it from your database, and then you can try to protect against further comment spam based off who is trying to spam you.
    For instance, a WordPress site today had these unique IPs that were trying to spam them:
    8 218.10.17.148
    8 60.173.26.43
    8 60.173.26.61
    9 218.10.17.208
    9 218.10.17.94
    9 60.173.10.231
    9 60.173.10.242
    9 60.173.10.244
    9 60.173.11.219
    9 60.173.26.47
    9 60.173.26.57
    So we can see that there are a lot of unique IP addresses from the 60.173 range, and the 218.10 range that are trying to spam our comments at least 8 times each.
    Now you can try to see where these IP addresses are from using a website like geoIPtool.com
    In this case you'd end up looking at:
    http://www.geoiptool.com/en/?IP=60.173
    http://www.geoiptool.com/en/?IP=218.10
    These ranges are all from China, so if that's not your target audience, there probably shouldn't be people from there commenting on your website.

    Block IP ranges from accessing your website at all

    You can outright deny these IP ranges in .htaccess with this:
    Deny from 60.172
    Deny from 218.10

    Block IP ranges from commenting on your WordPress site

    Or if you wanted to still allow people from these IP ranges to visit your site, but not comment on it, you could use these .htaccess rules:
    ErrorDocument 503 "Commenting disabled"
    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} ^60.173 [OR]
    RewriteCond %{REMOTE_ADDR} ^218.10
    RewriteCond %{REQUEST_URI} ^/wp-comments-post.php$
    RewriteRule .* - [R=503,L]
  8. Limit or disable WordPress revisions

    Although not as intensive as preventing requests in the first place, you can also disable or limit WordPress revisions to improve database performance as well.
  9. Update everything WordPress

    To ensure everything is running optimally be sure to update regularly.
How to fix the WHMCS issue the ticket replies are not arranging in range.
The issue was caused due to PHP,Mysql,Server Time are conflicting so you need to Make sure that all the timezone are same First check the timezone of your server.

I have set my server timezone to : Asia/Kolkata in Server as Default.MYSQL will use the same system default timing.But We need to make sure that PHP was using the same time or it was use something different.While checking my server i have seen that PHP Timezone was "UTC" Which was causing the issue.

I have changed the PHP Timezone to Asia/Kolkata and the issue got fixed

You can change the timezone in php.ini or from WHM Root > PHP Configuration > Advanced Mode > Search for "Timezone" and update the timezone which you need

You can get the list of time zone here : http://php.net/manual/en/timezones.php



  1. Log into your 1&1 account.
  2. Go to your Domain Manager. Depending on the type of package you have, the way you get to your domain manager may be slightly different.
  3. Select New > Create Subdomain.
  4. In the empty box, type NS1.
  5. From the drop-down box, select the domain for which the nameservers are being created.
  6. Select OK.
  7. Repeat steps 3 through 6 for NS2.
  8. Check the box next to NS1.YourDomain.TLD.
  9. Select DNS > Edit DNS Settings.
  10. In the Advanced DNS Settings, select Other IP Address.
  11. Enter the IP address of NS1.
  12. Click OK.
  13. Click Go To Overview.
  14. Repeat steps 7 through 12 for NS2.
  15. Check the box next to the domain you wish to point to your private nameservers.
  16. Select DNS > Edit DNS Settings.
  17. In the Basic DNS Settings section, select My name server from the drop-down menu.
  18. In the Advanced DNS Settings section, find Primary name server and enterNS1.YourDomain.TLD.
  19. In the Advanced DNS Settings section, find Secondary name server and enterNS2.YourDomain.TLD.
  20. Click OK.
  21. Click Go To Overview.
You can check your work by selecting DNS > Show DNS Settings. It can take up to 48 hours for your new private nameservers to propagate.
How to use custom php.ini file to increase memory limit,upload size,adding extension and more works.
Before doing on this the server should able to support custom php.ini configuration (All our servers support custom php.ini config's)

How to create an file ?
* Login to your cPanel > Filemanager
* Create an new file named "php.ini" (Note : the file should be created inside /public_html Directory)
* Edit the file using the editor

If you need to increase the memory limit use the following code :

memory_limit = 32M;

You can view the list of PHP Directives to set your configuration

http://php.net/manual/en/ini.list.php

To confirm the made changes you can use the phpinfo file :

Create an file named "phpinfo.php" inside /public_html

Paste the below code and save the file
<?php
phpinfo();
?>

It will show the PHP Configuration :)
How to check the top Resource Consuming process/users under cPanel/WHM Server.The common command to check the resource will be "top" and we can use c,m,i,etc,..

Did you heard about the Tool name "atop" Resource monitoring tool ?

About aTop :
ATOP is an advanced interactive monitoring tool to analyze the load and hardware resources on a Linux system. It shows the CPU, Memory, Disk and Network resource usages. Atop gives the resource occupation on system level followed by the information of processes that have been active during the time interval (10 seconds default).
How to Install atop inside the server ?
Login to your server using ssh (putty)
[~]# wget http://pkgs.repoforge.org/atop

[~]# yum install atop

Once the package has been installed you can enter the command "atop" to check the resource monitoring tool .

In an Atop window , various system activity reports can be generated by using different keys:
Key m : Memory consumption
Key d : Disk utilization
Key s : Scheduling information
Key v : Variable information
Key c : Command line
Key p : Accumulated per program
Key u : Accumulated per user
Key n : Network utilization

How to check old logs ?

When atop is installed, a cronjob is activated to run a background incarnation of atop that writes compressed samples to a log file in raw format.
These log files can be found in the directory /var/log/atop. When the command "atop -r" is started, today's log file will be shown. When specifying another date as argument, the concerning log file will be shown.
For example: To view log file corresponding to the date 23rd June 2012, you can use the following command:
[~]# atop -r 20120623


How to check the list of Root and Users cron jobs using an perl script easily.It's not easy to find all the cron jobs using the cron -u command if the server has 1000 account then the System admin will be confused or get mad on doing this..Lets make this simple using an perl script which will print all the cron jobs(ROOT + cPanel users) in an .txt file which will be easy to optimize the server performace

Perl script code :
#!/bin/bash
cd /var/spool/cron
ls -1 > /cronusers

for i in ` cat /cronusers`


do


echo "#########################CRON DETAILS FOR USER $i " >> /crondetails

echo "" >> /crondetils
cat $i >> /crondetils
echo "" >> /crondetils
echo "####################################################" >>/crondetails
echo "" >> /crondetils

done


Login to your Server using Putty(SSH) :
Create an file under /root/ using the following command : vim /root/croncheck.sh
Paste the code inside the file then save the file using :wq
Change the permission of the file to 755 using the command : chmod /root/croncheck.sh
Now run the script using : ./croncheck.sh

Once the script execution completed you can see the list of cron under the /crondetails

Command :
cat /crondetails

You can download the file to your PC using WINSCP or move the file to any of your hosting account and download from the cPanel

Command to move the file :
mv /crondetails /home/username/public_html

Command to copy the file :
cp /crondetails /home/username/public_html


Note : username = Username of the cPanel account where you need to move/copy the file :)



Commands to scan for virus using Clamav from SSH Root end :

The below command will scan the the mentioned directory "/home" and show the Result below but it will not generate any logs for check for Malware paths (You can change the directory /anything)


/usr/local/cpanel/3rdparty/bin/clamscan -r /home/

The below command will start the scan and create an Log file in the path /var/log/clamav-scan.log which will be used to check the malware path's :


/usr/local/cpanel/3rdparty/bin/clamscan -r /home/ >> /var/log/clamav-scan.log



How to mount the Backup storage (500 GB) Provided by OVH inside an cPanel/WHM Server?
I can't able to find any tutorials about this over internet in any forums or blogs so i made this post :)

First login to your Root using SSH (Putty) :
I used cifs to mount the 500 Storage in my Server.So i will show you how to do this using cifs.

First install the package of CIFS before mounting

yum install cifs-utils 

Run the above command to install the cifs packages now goto the next step :

mount -t cifs -o sec=ntlm,uid=root,gid=100,dir_mode=0700,username=root,password= //FTPBACKUPHOST/SERVICENAME /mnt/DIRNAME


Password : Mention the password you received from OVH After creating backup storage (Note don't mention your Server Root password)

Ftpbackuphost : Mention the ftp server link which you got in Email with Backup storage password

Service name : Mention the server name provided by OVH (Ex : ns0000000.ip-123-123-123.net)

/mnt/DIRNAME : You can mention any directory there..I recommend /backup which will be easy to look for backups (note : create the directory using "cd backup"

Now press the enter if it shows any error you made something wrong.

How to check if the Storage was mounted :
1. Login to your SSH > cd /backup > You will see an file .banner > cat .banner it will show the details
2. Login to your WHM Root >  Show current Disk space > It will show the Mount point with the Details

Now you can enable the backup from WHM > Backup/Legacy backup configuration and if you need to do backups only for Selected users use the option "WHM > Backup User selection"

How to test if the backup is running ?

You can run the following command to check on the server

/scripts/backup --force  (This command is for backup)
/scripts/cpbackup --force (this command is for Legacy backup)



To check the Traffic of the site use the below command :

grep "10/Apr/2015" /usr/local/apache/domlogs/cpanelusername/domainname

You can change the Date as per your check

To check the Bot access (Google,bing,Baidu,etc,..) Use the below command : 

grep "10/Apr/2015" /usr/local/apache/domlogs/cpanelusername/domainname |grep -i bot

To check Maximum Visited IP's for the Domain : 

grep "10/Apr/2015" /usr/local/apache/domlogs/cpanelusername/domainname |awk '{print $1}'|sort|uniq -c|sort -n|tail -30

It will show the Last 30 Maximum Visited IP's of the Domain from the Domlogs




Table corruption in MySQL is a very frequent issue. This primarily happens due to failed/forced transactions. MySQL primary supports two type of engines MyISAM and InnoDB. It is to be noted that the repair utility provided by MySQL can only be used for tables using MyISAM. Crashed tables using InnoDB cannot be repaired using the repair tool. Now, the commands to repair tables/databases in MySQL are as follows:
mysqlcheck -A  [To check and repair all databases on the server]
mysqlcheck -r Database_name [where Database_name is the name of the database to be checked]
Another thing to be noted here is that the -r option can fix everything except unique keys that aren’t unique.
Control panels like cPanel provide an option to repair tables from the interface itself. In cPanel this can be done via cPanel >> MySQL Databases >> Modify Databases >> Check DB. However, please note that this will work for MyISAM tables only.
Log files on cPanel servers are not stored at the same location of the default OS installation. The locations of common log files are shared below.


Apache
Apache is the web server that is typically utilized by cPanel.  On cPanel servers Apache does write to a rather high number of logs as each site has its own traffic log.

/usr/local/apache/logs/access_log
The access_log is used to log all http requests received. These requests can be valid or invalid. All of this gets logged in the access_log file.

/usr/local/apache/logs/error_log
On cPanel servers all Apache errors, regardless of site, are logged in the error_log file.

/usr/local/apache/domlogs
Within the domlogs folder each site on the server will have its own log file.  These files will be the fully qualified domain name for the domain, ie abc.com, xyz.com.  All http traffic to a site will be logged in this log file.

Exim
Exim is the MTA(Mail Transfer Agent) that cPanel utilizes.  Exim has three primary logs, but only two of these logs contain useful information

/var/log/exim_mainlog
The exim_mainlog contains ALL interactions that exim handles, so both incoming and outgoing mail transactions.

/var/log/exim_rejectlog
The exim_rejectlog contains all connection attempts that were denied.  This information is also logged in the exim_mainlog.

cPanel
cPanel does log all http traffic to WHM, webmail, and cPanel access.  All cPanel logs are located in the /usr/local/cpanel/logs directory.

/usr/local/cpanel/logs/access_log
This access_log contains all traffic to WHM, cPanel, and webmail over http.

/usr/local/cpanel/logs/error_log
This error_log contains all errors that occur when accessing a cPanel related site over http or https.

FTP
Regardless of  the FTP server you use, cPanel logs all connections, uploads, and downloads into the system messages log file located at

/var/log/messages
All FTP transactions are recorded in messages.  This file also has a lot of other messages with the FTP transactions.

MySQL
The MySQL log will contain all actions related to start/stop/restart of the service along with errors if any.

/var/lib/mysql/hostname.err