Help, My Server Reboots Randomly! What Could Be the Causes?

There are times when misfortune strikes when you least expect it. Server reboots can make your life a living hell. At first you might panic a bit as you try to find out what causes the server to reboot on its own. It is hard to keep calm when your system has become unstable. There are many reasons why a server reboots randomly. When it happens to your server, check out the tips below and find out the real cause of the reboots.

Check Wattage of Power Supply

One of the reasons why servers become unstable is the lack of juice that flows in the system. The power supply is one of the most important components in the server because it delivers the needed power for the other parts of the system to work. A defective or inadequate PSU can cause random reboots or hangs. Common issues with a power supply include stopping to work; output is not the specified wattage, or overheating. There are also times when the output is less than the total energy consumption of the components.


Picture of a Google Data Center (Foto: Google)

Look at the Bios Settings

There are times when problems with the BIOS can cause random reboots. That’s why it is vital that you check the BIOS setting to rule out the BIOS as the root of your server’s problems. There are instances when an empty BIOS battery has made a system instable. You can also program the boots and shutdowns of the server through the BIOS settings. Sometimes a problem with the server can be solved by updating the BIOS.

Monitor Temperature of the Server

Another issue that you should consider when your server reboots randomly is overheating. When your system overheats, the server will crash or reboot on its own. You should monitor the temperature of your system and find out whether it is overheating or not.

Check Power Connections

There are times when the connection of the server to the electricity supply is the problem. Make sure that it is plugged in properly into the outlet. You should also check if the mains lead is plugged completely into the back of the system. If the server is plugged into a UPS, make sure that the UPS is not the problem. Try to plug the system directly into an outlet and see if the reboots still occur.

Check Transistors of the Motherboard

Random reboots can be caused by bad hardware. Check whether all the transistors of the motherboard are okay or if they are burnt. If you find burnt transistors, you can either replace them or replace the motherboard as a whole.

Check the RAM

The server might be rebooting because it lacks RAM. You might not have noticed, but one of your RAMs might not be functioning anymore. Test your RAMs to find out if they are still in good working condition.

If you have gone through all the above and still experience random reboots, then the last resort is to remove all the components and connections, and rebuild the server. This is to ensure that the cause of the reboots is not loose connections.

Linux: How to clone and split screens using Xrandr

XRandr is a very handsome tool to deal with multiple screens in Linux. It allows to clone split, clone and re-arrange the output. It has been developed as official user-interface for the RandR protocol which serves to configure the X11 server. It is a bit difficult to use. However, if you know some magic commands and create aliases the tool may still do some magic as will shown below. For the too trick we assume that you are using a laptop with a VGA port where an external screen is plugged in.

In the first exercise we just want to clone this external screen:
[sourcecode language=”bash”]
xrandr –output LVDS-0 –auto –output VGA-0 –auto –same-as LVDS-0
After executing that line you should just have a exact copy of your screen on the external one connected by VGA.

I the second exercise we want to split the screen between the Laptop screen and the external one.
[sourcecode language=”bash”]
xrandr –output LVDS-0 –primary
xrandr –auto –output VGA-0 –mode 1920×1080 –right-of LVDS-0
This example adds the external screen right of your laptop screen. With the –left-of option you can add it at the opposite site.Make sure that you have to choose a resolution which is supported by both screens.

Get the NTP time in a C++ programm via a simple socket

If you are writing an application it sometimes my be useful to have the exact time. Usually the time of the operating system is not synchronized. However, there is a very old protocol which available which allows servers so synchronize themselves: The Network Timing Protocol (NTP). It uses UDP port 123 for its communication. There is a huge network of free NTP time servers available in the web. The following example program connects to such a timing server and retrieves the NTP time from that server. For that it opens a simple socket connection in C++. The program can be compiled executed as it is here without any changes and also calculates the difference between the NTP time to your current system time. Furthermore you also learn how to use sockets in C++. We create a simple massage here, sent it via a socket to the NTP timing server and then receive the reply which is the desired time.

[sourcecode language=”cpp”]
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <time.h>
#include <string.h>
#include <iostream>
void ntpdate();

int main() {

return 0;

void ntpdate() {
// can be any timing server
// you might have to change the IP if the server is no longer available
char *hostname=(char *)"";
// ntp uses port 123
int portno=123;
int maxlen=1024;
int i;
// buffer for the socket request
unsigned char msg[48]={010,0,0,0,0,0,0,0,0};
// buffer for the reply
unsigned long buf[maxlen];
//struct in_addr ipaddr;
struct protoent *proto; //
struct sockaddr_in server_addr;
int s; // socket
long tmit; // the time — This is a time_t sort of

// open a UDP socket
s=socket(PF_INET, SOCK_DGRAM, proto->p_proto);

//here you can convert hostname to ipaddress if needed
//$ipaddr = inet_aton($HOSTNAME);

memset( &server_addr, 0, sizeof( server_addr ));
server_addr.sin_addr.s_addr = inet_addr(hostname);

* build a message. Our message is all zeros except for a one in the
* protocol version field
* msg[] in binary is 00 001 000 00000000
* it should be a total of 48 bytes long

// send the data to the timing server
i=sendto(s,msg,sizeof(msg),0,(struct sockaddr *)&server_addr,sizeof(server_addr));
// get the data back
struct sockaddr saddr;
socklen_t saddr_l = sizeof (saddr);
// here we wait for the reply and fill it into our buffer

//We get 12 long words back in Network order

* The high word of transmit time is the 4th word we get back
* tmit is the time in seconds not accounting for network delays which
* should be way less than a second if this is a local NTP server

tmit=ntohl((time_t)buf[4]); //# get transmit time

tmit-= 2208988800U;
std::cout << "NTP time is " << ctime(&tmit) << std::endl;
std::cout << "System time is " << (i-tmit) << " seconds off" << std::endl;


The Link Building Strategies which will hold in 2015

In a nutshell, link building is getting other websites to link to your website to improve the site’s rankings in search engines. Take note that Google will punish your site if you have too many spam links. Be careful how you implement your link building campaign. You might raise a red flag, and this can affect your page ranking. Below are useful tips in coming up with your link building strategies in 2014.

Avoid Link Networks

One of the most important tips to help you formulate link building strategies in 2014 is to avoid link networks. Google consider links from link networks as low quality and will be bad for your own website. The search engine giant has warned against the use of such schemes, and that’s why you should avoid them.

Stop Guest Blogging

Since the start off 2014, Google has turned its attention to guest blogging, especially the low-quality ones. The search engine considers the practice to be spammy and no longer good unlike in the past. Guest posts that have inauthentic or rehashed content are greatly discouraged by Google. So it will be a bad idea to consider guest blogging as part of your link building strategy.

Do not provoke your site getting hit by the Penguin: The so called penguin algorithm by Google punishes sites with spammy link building approaches.

Directories have Less Impact than before

Automated directory submissions should be avoided and must not be part of your link building strategies in 2014. When you use such service, you don’t have any control on where your links will come from. The practice provides more risks than rewards.

Questions and Answers are Good for Link Building

Question and Answers sites, such as Yahoo Answers and Quora, are good for link building. You can also use the sites as sources of inspiration for contents of your blog. You can check the top questions on Yahoo Answers and look for ones that you can answer better. Then write a blog post with as much helpful info as possible. After posting the article, summarise your post as an answer to the question in Yahoo Answers and leave a link to your blog post.

Write Unique Content

Unique content is one of the tried and tested ways to earn traffic and back links. That’s why it should be included in your link building strategies in 2014. Quality content will attract shares, links, and traffic.

Write Testimonials

You can earn media links when you write testimonials. Just make sure that you don’t overdo it. You must also do it for products that you actually like. This will ensure that you give out a genuine feel about the product and not just a generic testimonial.

Do Social Marketing

Link building strategies in 2014 and 2015 must include social marketing. Social networks allow you to engage your audience and in turn they will share links from your website that they find interesting. You should be more active in your social networks, especially Google Plus.

No Follow Links Counts in Link Building

In general, Google doesn’t give any importance to No Follow links. The website doesn’t get any Page Rank benefits from them, but that doesn’t mean that they are unimportant. A link is still a link, and they can bring traffic as long as people see them. Plus, other search engines might handle No Follow links differently.

Add a Blog to Keep Website Fresh with New Content

Content is king when it comes to online marketing, and there’s no better way to have fresh content than running a blog. That’s why starting or maintaining a blog should be one of the link building strategies in 2014 and beyond.

The Colorfull World of Digital Currencies

While the author James Rickards is already predicting the collapse of our current monetary system in his book “The death of money” the web is working at an alternative. You might have heard of these digital currencies already which are currently emerging and disappearing again in the web. You certainly have read already about Bitcoin, the pioneer among these currencies which has reached already a quite wide range of acceptance meanwhile. Some years ago the first pizza has been sold for this freshly coined digital money. Meanwhile you can buy almost anything for Bitcoins.

Meanwhile there are many more and some already have disappeared again. The three big players at the moment are Bitcoin, Litecoin and yes, you are reading correctly Dogecoin. While Litecoin only technically differs from Bitcoin Dogecoin is going a step further, bringing a social component in the world of internet money. The Dogecoin community has gained more than 80 000 members which are organizing social and charitiy events. They have been supporting some water project in Kenya, sent the Jamaican Bobsled team to the last Olympic games in Russia and even sponsored their own team at NASCAR. If money can be fun then Dogecoin is the monetary system which got closest the that maxim.

What all these cyber currencies have in common is that they are organized on a peer-to-peer base like application like Skype. This means that there is no central authority issuing the money but the money is created based on a mathematical algorithm. Everybody can participate in that process which is called mining. In the wild days of digital money you could do so just with your PC or your laptop. Meanwhile things have changed there. To mine a reasonable share of the coins which are issued on has to buy some special hardware which is difficult to get. If you are one of the lucky guys who manged in organizing such a device you can just watch your magic machine creating your own money which you can use to buy real goods. If you mine enough you can even buy a house. In the last years there has been a dramatic gold-rush concerning this new form of currency.

The year 2012 has been the year of Bitcoin, if you boght them before you were well off. Then 2013 could be called the year of Litecoin. How about Dogecoin then? It has been found end of 2013 and was accompanied by a incredibly wave of media coverage. Meanwhile it has survived long enough on this colorful market to be the next coin to skyrocket. Some technical changes implemented by the developers team recently might support this development. Who knows but maybe 2015 will become the year of Dogecoin in this unpredictable world of digital money.

Howto wait for multiple threads in C++

Whenever you have to deal with threads in C++ you should think of using the boost libraries which offer high end solutions for dealing with threads and creating thread-safe applications. A really nice feature on top of this are thread groups which allow you to manage multiple threads very easily. The following code snippet illustrates how to wait for multiple threads using such a thread group.

[sourcecode language=”cpp”]
#include <boost/thread.hpp>
#include <boost/thread.hpp>

void myFunc(int param)
std::cout << "Hello world" << std::endl;

int main()
int numberOfThreads==4;

boost::thread_group thread_group;

for(int counter = 0; counter < numberOfThreads;counter++)
thread_group.add_thread(new boost::thread(myFunc,5));


std::cout << "Done!" << std::endl;

The code executes the function “myFunc” in a separate thread which is added to a thread group. This happens four times. The trick of executing the threads simultaneously is done by the join_all() command. The program waits until the last thread has finished and then is done. There is no magic about threads at all using boost. It is straight-forward and easy.

How can I backup a MySql Database or export it to a file?

Imagine you have a large MySql database and want to backup it or backup your wordpress blog which also uses a MySql database. There is nothing easier than just using the handsome mysqldump command. It writes all the information to a sql script which you then can use to restore the databases at any machine you want. It is only two steps to create the script and restore the database.

To export the database just use the following command:

mysqldump -uroot -pmypassword –all-databases > backup.sql

In that case just all databases will be backed up. Of course the command also offers options to backup single databases.

If you want to restore the database you have backed up later you can doing by the following even shorter command:

mysql -u root -p < alldb.sql

One common error mysql dump might throw is the following one:

mysqldump: Couldn’t execute ‘show fields from `general_log`’: Can’t create/write to file ‘/tmp/#sql_63f9_0.MYI’ (Errcode: 2) (1)

If you get it do not panic! It is usually simply a permissions issue or a problem with discspace. You must make sure that the “mysqld” user has the permissions to write its tmp directory (in this example it is /tmp). If not your will get this error.

If you verified that you really have enought disc space and futhermore the permissions are correctly set but exporting your sql database still does not work there might be another cause for the problem:

You might get this error if you are using an older version of mysql in combination with a newer version of a Read Head based linux system (e. g. Fedora). There have been bug reports that the OS does not allow mysql to the directory /tmp. This is really odd but in my case really was the cause of the problem! The solution here is also an easy one, if you find it:
vi /etc/my.cnf

Then add the tmpdir variable to the [mysqld] section:


In a last step just restart the mysql deamon:
/sbin/service mysqld restart

You will not believe how smooth the export feature is now working. Enjoy!

Find and Replace all occurrences of a word with VIM

This post will be short one. If you have to work at remote servers with really slow internet connections and also have to edit files there you might get stuck with VIM. Yes sure, this program does not have a graphical user interface but it is extremely powerful! Do not underestimate it. One of the most common tasks for a text editor is finding and replacing a word or a entire pattern of course. Since VIM commands are a bit cryptic sometimes they are easy to forget if you do not use them on a daily base. The following one does replace one pattern by another one in the entire file. If your file is large this saves you a lot of typing!

%s/orignial pattern/new pattern/g

Thats it. If you want to use special characters you have to put a “\” in front of them.

A space in vim can be replaced using “\s” or if it is more than one space “\s\s\s”

For tabulators you can use the pattern “\t”.

Howto extract the text between two key words in Bash

Are you having a text file with a repeating pattern of key words and want to extract the content which is written between these keywords. Your file could look like the follows

this is not interesting
this is the text I Want to extract
also this line should be skipped
I want also this text
And this one
ignore this text

and so on. As you can imagine Bash offers all the tools you need to do the trick. There are plenty of ways to achieve the goal of extracting the text between the keywords from your file. My favorite bash command to do so is the following one.

[sourcecode language=”bash”]
awk ‘/^hello$/,/^world$/ { print }’ input.txt > output.txt

In case input.txt contains the example line above output.txt will only contain the lines between the key words. The keyword embracing the interesting text will remain in in the output file. You easily can remove them e.g. by using the find and replace feature of vim or any other text editor.

Life can be that easy!

Now is the time to switch to secured connections via SSL. Howto for Apache 2.4

Since a couple of moths Google is using SSL as a ranking signal which means that the use of secured SSL connections will improve the ranking of your page in the Google Serp. Furthermore it will increase the trust in your project if you use SSL connections. Switching to SSL is has never been easier than now. Here a short step-by-step guide which is showing you how to make your website secure.

Step 1: Create your a private and public key

The first thing you have to do to get started with encrypting your website is getting creating a SSL key and a certification request file based on that key. Using Linux this step is very easy. Just execute the following tow commands.

[sourcecode language=”bash”]
openssl genrsa -out mykey.key 2048
openssl req -new -key mykey.key -out mykey.csr -config req.conf

The directory where you execute the command has also to contain the following req.conf:

[sourcecode language=”text”]
[ req ]
default_bits = 2048
default_keyfile = mykey.key
distinguished_name = req_distinguished_name
req_extensions = req_ext # The extentions to add to the self signed cert

[ req_distinguished_name ]
countryName = US
countryName_default = US
stateOrProvinceName = Colorado
stateOrProvinceName_default = Colorado
localityName = Denver
localityName_default = Denver
organizationName =
organizationName_default =
commonName =
commonName_max = 64

[ req_ext ]
subjectAltName = @alt_names

DNS.1 =
DNS.2 =

Important: The [ req_ext ] and [alt_names] sections are only needed if you want to issue a certificate which is valid for multiple domains. Otherwise you can just leave these tow sections out.
Step 2: Now we arrived at the time where you have to issue your SSL certificate. You can either do that for free or get a commercial certificate. The advantage of the latter solution is that these certificates are recognized by all common web-browsers while the free certificates still have some acceptance issues.

A a really good provider of free SSL certificates is The acceptance of these free SSL certificates will increase with the time so it is definitely worth considering this option. If you decide to get a non-free certificate you might have a look at or to get cheap ones.

The certificates are simply issued after you uploaded your CSR Request file you have created before. If you got your certificate the only thing missing is to correctly setup your Apache Webserver

Step 3: Configure your webserver to use the SSL Certificates
The easiest way to do is to use virtual hosts. Adding the following two configs to your webserver will do both enable SSL and also maintain the normal HTTP connection.

[sourcecode language=”text”]
<VirtualHost *:443>

<Directory "/var/www/html">
Require all granted

DocumentRoot /var/www/html
SSLEngine On
SSLCertificateFile /etc/httpd/conf.d/ssl.key/cert.crt
SSLCertificateKeyFile /etc/httpd/conf.d/ssl.key/djvupdf.key
SSLCACertificateFile /etc/httpd/conf.d/ssl.key/

<VirtualHost *:80>
DocumentRoot /var/www/html

<Directory "/var/www/html">
Require all granted

The files cert.crt and will be provided by your certification authority after the transaction has been completed.

Step 4: Solving SEO issues and testing your SSL configuration
Now you are done already. Your server is reachable via secured connections now. You can test if your SSL configuration is up-to-date at the following site:

If you get an A+ to A- there you are completely fine.

In case you did not disable the normal HTTP connection to your server there is a little issue with duplicate content you should solve. Search engines do not like duplicate content therefore you should tell them which is the preferred version of your site. This can be done easily by including the so-called canonical tag to the header section of your pages and setting it to the https:// URL of the particular page. This will fix those issues. Make sure, that the URL is exact!

A example how this looks like is the following line. Make sure to put it in the head section:

[sourcecode language=”text”]
<link rel="canonical" href="" />