How to Run aria2 in Background as Daemon?
This article provides a quick overview and a step-by-step guide on how to run aria2, the lightweight multi-protocol download utility, in the background as a persistent daemon process. Operating aria2 as a background service allows you to pass download tasks to it remotely or via scripts without keeping a terminal window open. You will learn the core command-line flags required for background operation, how to manage the process, and how to configure it to start automatically on system boot.
Running aria2 as a Daemon via Command Line
The simplest way to start aria2 in the background is by utilizing its built-in daemon flag along with the Remote Procedure Call (RPC) interface, which lets you control the download manager after it has been detached from your terminal.
To launch aria2 as a daemon, open your terminal and execute the following command:
aria2c --enable-rpc --rpc-listen-all --daemonKey Flags Explained
--daemon: This is the crucial flag that tells aria2 to fork into the background and detach itself from the current terminal session.--enable-rpc: This enables the JSON-RPC and XML-RPC interfaces, which are necessary to send download links to the background process.--rpc-listen-all: This allows the RPC server to listen on all network interfaces, making remote connection possible (optional if you only plan to connect from the same machine).
Managing the Background Process
Because a daemon process runs silently without a user interface, you need alternative methods to check its status or terminate it.
To verify that aria2 is actively running in the background, you can
search for its process using the ps command combined with
grep:
ps aux | grep aria2cIf you need to stop the background daemon, you can gracefully
terminate the process by targeting its name with the pkill
command:
pkill aria2cAutomating aria2 Daemon with a Configuration File
Instead of typing long command-line arguments every time, you can
save your preferences into a permanent configuration file. Create a file
named aria2.conf in your ~/.config/aria2/
directory and add your settings.
Sample Configuration File
# Core Daemon Settings
daemon=true
enable-rpc=true
rpc-listen-all=false
rpc-secret=YourSecureTokenHere
# Optional Download Preferences
dir=/home/user/Downloads
max-concurrent-downloads=5
continue=trueSecurity Note: When running aria2 as a daemon with RPC enabled, it is highly recommended to include the
rpc-secrettoken in your configuration to prevent unauthorized users from triggering downloads on your machine.
Once your configuration file is saved, you can launch the background daemon simply by pointing to it:
aria2c --conf-path=/home/user/.config/aria2/aria2.confSetting Up aria2 as a systemd Service
For a truly robust setup on Linux systems, you can configure aria2 to start automatically whenever your computer boots up by creating a systemd service unit file.
Create a new service file at
/etc/systemd/system/aria2.service using a text editor with
administrative privileges:
[Unit]
Description=aria2 Download Manager Daemon
After=network.target
[Service]
Type=forking
User=your_username
ExecStart=/usr/bin/aria2c --conf-path=/home/your_username/.config/aria2/aria2.conf
[Install]
WantedBy=multi-user.targetAfter saving the file, reload the systemd manager configuration, enable the service to launch at boot, and start it immediately with the following commands:
sudo systemctl daemon-reload
sudo systemctl enable aria2.service
sudo systemctl start aria2.serviceYou can check the real-time operational status and logs of your
background downloader at any time by running
sudo systemctl status aria2.service.