Thursday, 4 September 2014

Disk space consumption

Command to get teh path of file which is consuming large disk space in the server:

du -a /home | sort -n -r | head -n 10

Core dump files

The possible reason for the core files getting generated is when a php process is killed, apache creates core files under your account.

If it is caused due to php/apache then you can get rid off those core files by editing the httpd start up file on the server end.
To Disable creation of core dump files:
root@server [~]# vi /etc/init.d/httpd
Search for ulimit lines .For eg : you can see these lines

ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384
You need to add ulimit -c 0 at the end. Which will look like :

ulimit -n 1024
ulimit -n 4096
ulimit -n 8192
ulimit -n 16384
ulimit -c 0

Save changes and quit.

Now kill / stop apache service and then start apache service on the server.

root@server [~]# service httpd stop
root@server [~]# service httpd stop
httpd (no pid file) not running
root@server [~]# service httpd startssl
root@server [~]# service httpd startssl
httpd (pid 21154) already running

Handling spamming


1:  Command to delete spam mails from a particular account

grep -lr user@domainname.tld /var/spool/exim/input/* |  xargs rm -vf


Symlinks

Command to disable all symlinks under a folder:

find -type l -exec unlink {} \;

Updating SPF for all accounts in cPanel servers

One way of fixing:

The /usr/local/cpanel/Cpanel/SPF.pm file handles the SPF installation script that runs "/usr/local/cpanel/bin/spf_installer username" and is also used in cPanel > Email Authentication area for setting the IP for the SPF record. First, make a backup of the file:

cp /usr/local/cpanel/Cpanel/SPF.pm /usr/local/cpanel/Cpanel/SPF.pm.bak

Now revise the lines that have this:
my $mainip = Cpanel::DIp::getmainserverip();

To have this instead:


my $mainip = '192.12.12.12';

This will then use the hard-coded IP when installing the SPF records. This will occur for all parked, addon, and subdomains on the account for the SPF installation. Whenever the user in cPanel > Email Authentication area enables SPF records, the hard-coded IP will be used.

Please note that the code entry occurs thrice in the file, so you would need to revise all the entries. If you only revise the initial entry, only the main domain will be changed to that new hard-coded IP, while parked, addon, and subdomains will not be.

You may also want to put that file into the exclude list for cPanel so it does not get overwritten on cPanel updates:

echo "/usr/local/cpanel/Cpanel/SPF.pm" >> /etc/cpanelsync.exclude



Script to update SPF for all accounts

#!/bin/bash
IFS="$"
cd /var/named
/bin/ls -- /var/cpanel/users | grep -v "root\|system\|passwd\|cpanel\|nobody\|mysql\|\`\|\-\|\." | while read CPUSER; do
echo "Installing SPF for '${CPUSER}'";
/usr/local/cpanel/bin/spf_installer "${CPUSER}" > /dev/null
done

Exim syntax error

Issue Error Messages:
SMTP call from (workstation) [IP] dropped: too many syntax or protocol errors (last command was "RCPT TO:

Solution:
When sending emails using outlook you might receive the error above. It seems that when you copy & paste the email addresses into the To field, they include quotations around them that the server did not know how to handle (i.e. ‘name@website.com’ instead of just name@website.com).

Remove the quotations & then try sending emails.