Install htop via the QNAP App Center or Entware package manager to gain a superior interactive process viewer compared to the default top command. Use nohup combined with an ampersand to detach long-running SSH tasks from your terminal session, ensuring they continue executing even if you disconnect unexpectedly.
Prerequisites for Intel-Based QNAP Systems
Before diving into command-line utilities, ensure your Intel-based QNAP NAS is running QTS 5.1 or a later version. These instructions rely on standard Linux environments available through either the built-in App Center or third-party package managers like Entware. If you are using a newer ARM-based model, the package repositories may differ significantly, but this guide focuses specifically on x86_64 architecture found in most Intel-powered devices. You will need SSH access enabled on your NAS. Navigate to Control Panel > Network & File Services > Telnet / SSH and check Enable SSH Service. Set the port to 22 unless you have specific security requirements mandating a non-standard port. Connect using a terminal client such as PuTTY on Windows or Terminal on macOS/Linux. Enter your admin credentials when prompted. Having root access is not strictly necessary for installing user-space applications, but it simplifies system-wide configurations.
Installing htop for Process Monitoring
The default
top command in Linux provides basic process information but lacks interactivity and visual clarity.
htop offers a colorful, mouse-friendly interface that displays CPU, memory, and swap usage in real-time. It allows you to sort processes by various metrics and kill them directly from the interface without knowing their PID numbers.
If your QNAP NAS has the App Center installed, search for "htop" and install it directly. This method handles dependencies automatically and places the binary in a standard path. For more advanced users who prefer package management similar to Debian or Ubuntu systems, Entware is the recommended approach. First, ensure Entware is installed on your device. If not, follow the official installation script for your specific hardware platform. Once Entware is active, open your SSH session and run the following command to update the package list:
opkg update
Next, install htop using the package manager:
opkg install htop
After installation, verify the setup by typing
htop in your terminal. You should see a grid of processes with clear headers for CPU, MEM, and SWAP columns. Press F10 to quit the application. This tool is particularly useful when troubleshooting high CPU usage caused by background indexing or network shares. For related networking issues that might affect performance monitoring, consider reviewing our guide on fixing random disconnects with Intel I225-V adapters
QNAP NAS: Fixing Random Disconnect Issues with Intel I225-V Network Adapters.
Using nohup for Persistent Sessions
When running long scripts, large file transfers, or complex compilations over SSH, a dropped connection can terminate the process. The
nohup command (short for "no hangup") prevents the shell from sending a SIGHUP signal to the process when the terminal closes. Combine this with the ampersand (
&) to run the job in the background.
For example, to run a backup script named
backup.sh persistently, use:
nohup ./backup.sh > backup.log 2&&1 &
This command redirects both standard output and standard error to
backup.log, preventing clutter in your terminal. The trailing ampersand sends the process to the background immediately. You can then safely close your SSH window. To monitor progress later, reconnect via SSH and tail the log file:
tail -f backup.log
This technique is essential for maintenance tasks that span hours. It eliminates the anxiety of losing progress due to unstable Wi-Fi connections or accidental laptop sleep modes. For deeper insights into background execution principles, refer to our article on understanding background script execution using nohup on Ubuntu Server
Understanding Background Script Execution using nohup on Ubuntu Server.
Managing Background Jobs
Once jobs are running in the background, you may need to manage them. Use the
jobs command to list all background tasks associated with your current shell session. If you need to bring a job back to the foreground, use
fg %1, replacing 1 with the job number. To suspend a foreground process, press Ctrl+Z, then resume it in the background with
bg. While
htop shows these processes visually,
jobs helps manage shell-level control. Note that
nohup jobs persist beyond the shell session, so they may not appear in
jobs after reconnection. Use
ps aux | grep backup to find them by name.
Troubleshooting Common Issues
Sometimes
htop may not display correctly if your terminal emulator does not support color codes. Ensure your SSH client is configured to accept ANSI colors. If
opkg fails to find htop, verify your internet connection and DNS settings on the NAS. Some enterprise firewalls block external package repositories. In such cases, manual installation from compiled binaries may be required, though this is rare for common tools. Regarding disk space,
htop consumes negligible resources, making it safe for continuous monitoring. Always ensure your QTS firmware is up to date to avoid compatibility issues with newer versions of these utilities.
Frequently Asked Questions
Can I use htop on ARM-based QNAP models?
Yes, but the installation method differs slightly. ARM models often use different package repositories or require precompiled binaries from community sources. Check the QNAP forum for specific Entware builds compatible with your processor architecture before attempting installation.
How do I kill a stuck process shown in htop?
Navigate to the process using arrow keys and press F9 to send a signal. Select SIGTERM (15) for a graceful shutdown or SIGKILL (9) if the process is unresponsive. Confirm the action to terminate the task immediately.
What happens to my nohup job if the NAS restarts?
Nohup jobs do not survive a system reboot. They are tied to the kernel's process table, which clears upon shutdown. You must schedule persistent tasks using cron jobs or QNAP's Task Scheduler for automatic restarts after power cycles.
Is nohup safer than tmux or screen?
Nohup is simpler for single commands but lacks session restoration capabilities. Tools like tmux allow you to detach and reattach to interactive shells, preserving input state. Use nohup for one-off scripts and tmux for long-term administrative work.
Why does htop show higher CPU usage than top?
Both tools read from the same /proc filesystem, but htop calculates averages differently across multiple cores. It may aggregate load in ways that appear higher initially. Trust both equally; significant discrepancies usually indicate a reporting bug in older htop versions.