Posts tagged ‘linux’

Forcing Linux To Shutdown Or Reboot

shutdown -r NOW
halt
reboot

not working for you?

To force a shutdown:

echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

And for a reboot:

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger


Thanks to Nasser Heidari for the tip.

PHP mail() with Ubuntu Desktop and Gmail

Recently I was adapting a newsletter plugin for WordPress and needed the PHP mail() function for testing. However an Ubuntu desktop install is missing Sendmail – the MTA that PHP expects to find on a Linux PC.

I use a local Apache/MySQL server on a laptop to do a lot of my development – I don’t need a full mail server just to send mail.

Also SMTP servers on dynamically assigned IP addresses are so untrusted these days that you can be pretty much guaranteed that a decent spam filter will reject your email based on a RBL lookup. By using Google Mail’s authenticated SMTP service you bypass this restriction.

The lightweight solution is ssmtp.
Continue reading ‘PHP mail() with Ubuntu Desktop and Gmail’ »

PHP: The include() include_once() performance debate

The include() include_once() performance debate

Updated with more tests on 2010-05-16.
Click here to jump to the 2010-05-16 update…

The conventional wisdom always said that PHP’s include()/require() was quicker than include_once()/require_once(), but recently I came across an interesting post by Arin Sarkissian which suggests otherwise. Also I found more commentary on the performance benefit of using relative versus absolute paths in include()/require() and include_once()/require_once() statements (although the main article’s conclusions contradict Arin’s experiments). The Drupal developers discussed and benchmarked the relative/absolute include() issue too.

So in keeping with the spirit of quick and dirty experimentation I hacked up some code and ran some tests on include()/require() against include_once()/require_once() and on the relative/absolute path issue. The results are pretty surprising and I love to hear some views.

Continue reading ‘PHP: The include() include_once() performance debate’ »

Migrating IMAP Email The Easy Way

email-iconMoving email servers has always been a royal pain for me. I’ve tried many of them over the years, and migrated from nearly as many of them. However the last couple of times I put myself through the pain I came across imapsync – an excellent script that will do an IMAP to IMAP migration across the wire.

Imapsync uses standard IMAP commands throughout, so is ideal for migrating from one brand of email server to another. (Of course there are still buggy IMAP servers out there, but well behaved ones will work fine.) It will transfer emails, folders, maintain message flags and folder subscriptions.

For best performance use the script on your new server (presumably it is much more powerful that the one you are migrating from) and make sure any obnoxiously large emails, junk, trash and other unwanted mail has been deleted (and expunged) first (see
Debug your IMAP server with Telnet for help with this.

Imapsync is written in Perl and is happy on almost any Operating System (yes even Windows!)

Debug your IMAP server with Telnet

terminalEmail by IMAP rocks – there are so many benefits to using it over POP3, particularly in an office environment. However many IMAP clients really suck when it comes to manipulating accounts with large messages. We recently watched a server brought to it’s knees during a email server migration – by an 165MB email containing wedding pictures that someone had decided to forward throughout the network!

At that stage you are better off talking directly to your email server with Telnet.
Continue reading ‘Debug your IMAP server with Telnet’ »