How to Clear the Linux Memory Cache

Clearning the Linux Memory cache can be a quick way to regain system resources. Writing to the drop_cache process will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.

  • To free pagecache:# echo 1 > /proc/sys/vm/drop_caches
  • To free dentries and inodes:# echo 2 > /proc/sys/vm/drop_caches
  • To free pagecache, dentries and inodes:# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation, and dirty objects are not freeable, the user should run “sync” first in order to make sure all cached objects are freed.

Example – Memory before:

[[email protected] ~]# free -m
total       used       free     shared    buffers     cached
Mem:          7860       7040        820          0        343       5076
-/+ buffers/cache:       1620       6240
Swap:         3999          0       3999

[[email protected] ~]# sync
[[email protected] ~]# echo 3 > /proc/sys/vm/drop_caches

Memory after:

[[email protected] ~]# free -m
total       used       free     shared    buffers     cached
Mem:          7860       1279       6581          0          0         33
-/+ buffers/cache:       1245       6615
Swap:         3999          0       3999

Plesk Qmail Error 5.4.6

I recently ran into a strange problem with Plesk 9.3 and Qmail. After completing the install of a new Plesk server I initiated migrations of production sites to it. Post migration the sites and email functioned normally for around 22 hours until suddenly all inbound email to the server bounced with the following error:

Nov 6 05:50:29 vh1 qmail-[27612]: Handlers Filter before-remote for qmail started ...
Nov 6 05:50:29 vh1 qmail-[27612]: [email protected]
Nov 6 05:50:29 vh1 qmail-[27612]: [email protected]
Nov 6 05:50:29 vh1 qmail-[27612]: hook_dir = '/usr/local/psa/handlers/before-remote'
Nov 6 05:50:29 vh1 qmail-[27612]: recipient[3] = '[email protected]'
Nov 6 05:50:29 vh1 qmail-[27612]: handlers dir = '/usr/local/psa/handlers/before-remote/recipient/[email protected]'
Nov 6 05:50:29 vh1 qmail: 1320533429.707838 delivery 233: failure: Sorry._Although_I'm_listed_as_a_best preference_MX_or_A_for_that_host,/it_isn't_in_my_control/locals_file,_so_I_don't_treat_it_as_local._(#5.4.6)/

The problem could be resolved by simply restarting Qmail but then the issue re-occured 22 hours later, immediately after nightly backups.

Parallels notes a fix for the problem at: http://kb.parallels.com/en/1380 but after running /usr/local/psa/admin/sbin/mchk then waiting 22 hours, the problem re-occurred. Continue reading “Plesk Qmail Error 5.4.6”

Plesk PCI Compliance

To reduce the risk of compromising sensitive data hosted on your server, you might want to implement special security measures that comply with the Payment Card Industry Data Security Standard (PCI DSS). The standard is intended to help organizations protect customer account data and enhance system security.

Parallels has released a comprehensive PCI Compliance guide for the Plesk hosting panel for both Windows and Linux. A full PDF copy is available here and an online version is available here.

I recommend using Parallels guide as it is maintained inline with industry standards.

Create a Linux Server Status MOTD

For those of us who manage multiple servers in multiple locations it can be beneficial to have a quick “system briefing” provided when we login to a Linux server via SSH. The Linux Message of the Day (MOTD) can be used for this.

I’ve created a simple script which will provide basic system information including the servers name, public IP, OS version, load averages, uptime etc.

To install the script:

1. Create a new text file named systemstats.sh:

# nano -w /usr/local/bin/systemstats.sh

2. Paste the following into the text file:

#!/bin/bash
#
# Server Status Script
# Version 0.1.3 m
# Updated: July 26th 2011 m

CPUTIME=$(ps -eo pcpu | awk ‘NR>1’ | awk ‘{tot=tot+$1} END {print tot}’)
CPUCORES=$(cat /proc/cpuinfo | grep -c processor)
UP=$(echo `uptime` | awk ‘{ print $3 ” ” $4 }’)
echo ”
System Status Continue reading “Create a Linux Server Status MOTD”

Putty 0.61 Released

PuTTY 0.61 is out, after over four years, with new features, bug fixes, and compatibility updates for Windows 7 and various SSH server software.

Features are new in beta 0.61 (released 2011-07-12) include:

  • Kerberos/GSSAPI authentication in SSH-2.
  • Local X11 authorisation support on Windows. (Unix already had it, of course.)
  • Support for non-fixed-width fonts on Windows.
  • GTK 2 support on Unix.
  • Specifying the logical host name independently of the physical network address to connect to.
  • Crypto and flow control optimisations.
  • Support for the [email protected] SSH-2 compression method.
  • Support for new Windows 7 UI features: Aero resizing and jump lists.
  • Support for OpenSSH AES-encrypted private key files in PuTTYgen.
  • Bug fix: handles OpenSSH private keys with primes in either order.
  • Bug fix: corruption of port forwarding is fixed (we think).
  • Bug fix: various crashes and hangs when exiting on failure,
  • Bug fix: hang in the serial back end on Windows.
  • Bug fix: Windows clipboard is now read asynchronously, in case of deadlock due to the clipboard owner being at the far end of the same PuTTY’s network connection (either via X forwarding or via tunnelled rdesktop).

The stand-alone executable can be downloaded from the snap-shot store here and the full package (which includes pscp, plink, psftp, pageant etc) here. As always, I recommend verifying the checksums using the MD5 list available here.