Commands to troubleshoot your websites | GreggHosting

The affects of Web Hosts on Your Business Website

Here're ways your choice of web hosting service provider impacts the performance of your business:


check

Website loading speed

check

Uptime and availability

check

Customer support

check

Security

check

Server location

Commands to troubleshoot your websites

Commands to troubleshoot your websites

troubleshoot

Overview

A website may not reply as soon as it should for a variety of reasons. This article explains how to troubleshoot your website and webserver using command line tools. All of the tasks below must be done via SSH on the server.

Uptime

The uptime command determines the current server load as well as the length of time the server has been up and operating. Although the load should often stay in the single digits, a spike is not uncommon. Consider the following scenario:

[server]

$ uptime 11:29:09 up 557 days, 12:30, 2 users, load average: 2.25, 2.49, 2.62 $ uptime 11:29:09 up 557 days, 12:30, 2 users, load average: 2.25, 2.49, 2.62 $ uptime 11:29:
This demonstrates the following:

When the command was executed
How long has the server been operational?
How many users are logged in (you and ‘root’ are the only ones)?
Average load for the last 1, 5, and 15 minutes
The load ‘across time,’ not the load at a single instant, is what you’re searching for.

TOP

The top command allows you to see the status of system tasks in real time. Examples of how to use this command can be found in the following article:
lsof

Using the command ‘top’ lsof
Run the following command assuming you’re running a PHP site. If you’re not using PHP, simply modify the grep php code to your preferred language:

When you run the command, make the following changes:

ssh username — this should be your SSH username.
[server] php — switch to the process type you’re looking for
grep php | grep /home php74.cgi 14963 username cwd DIR 8,17 4096 15115680565 /home/username/example.com/ $ lsof -u username | grep php | grep /home php74.cgi 14963 username cwd DIR 8,17 4096 15115680565 /home/username/example.com/
Ignore any errors in the response that you find. The list of open files for your PHP processes is what you’re looking for. You can then dig deeper into those files to figure out what the problem is.

‘lsof’ command troubleshooting
When you run ‘lsof’ for the first time, there might not be any useful output to work with. The watch command is used in the following example to run the lsof command every two seconds and send the results to a file named results.txt.

[server]$ watch “lsof -u username | grep php | grep /home | tee -a results.txt” [server]$ watch “lsof -u username | grep php | grep /home | tee -a results.txt”
As this runs, you may view the live output in your terminal. To stop it, use Ctrl + C after you’re done. After that, run the following command to see the entire output in the results.txt file:

cat results.txt [server]$
Run it again if the results.txt file contains nothing. Continue to execute it until you get a line of output indicating which domain or file is currently being used.
ps

ps The ps command displays a snapshot of the server’s running processes. Examples of how to use this command can be found in the following article:

To troubleshoot your website, use the ‘ps’ command.
Examine your access.log file

a logbook
Every GreggHost website saves information about the site in the access.log file. Because these logs can quickly grow enormous and difficult to read, you can use a few commands to quickly determine which site is receiving the most traffic. For more information, see the following article:

Login issues

Viewing and examining your access log via SSH
If you’re experiencing trouble entering into your site or server, the following articles will show you how to reset several sorts of passwords:

Passwords