Overview
This article details command line tools you can use to troubleshoot your website and webserver.
Prerequisites
This article assumes you have created a shell user and are able to log into your server via SSH.
Command-line tools
The following sections are popular command line tools you can use after logging into your DreamHost server via SSH.
Uptime
The uptime command checks the current server load and how long it's been up and running. The load should most often stay in single digits, but a spike is not uncommon. For example:
[server]$ uptime 11:29:09 up 557 days, 12:30, 2 users, load average: 2.25, 2.49, 2.62
This shows the following:
- Time the command was run
- How many days the server has been up
- How many users are logged in (this is 2, you and 'root')
- Load average for past 1, 5, and 15 minutes
What you're looking for is the load over a period of time, not necessarily the load at a single moment.
TOP
The top command allows you to view system tasks running in real-time. See this article for examples.
lsof
The lsof command lists open files. For example, this checks for open files under a specific user. The grep option is added to list only PHP files.
[server]$ lsof -u username | grep php
You can then look closer into those files to see what the issue may be.
Using 'watch' with the 'lsof' command
-
One problem with running lsof is that there may be no useful output at the moment it is run. To locate open files, add the watch command before the lsof command and output the results to a file named results.txt.
[server]$ watch "lsof -u username | grep php | tee -a results.txt"
You can see the live output in your terminal as this runs. When you're finished, click Ctrl + C to stop it. You can then view the full output in the results.txt file by running the following command:
[server]$ cat results.txt
If there is nothing in the results.txt file, run it again. Keep running it until you have a line of output that shows which domain or file is currently being used.
ps
The ps command displays a snapshot of running processes on the server. See this article for examples of how to use this command.