How to Load a Saved Session File in aria2?
When using the aria2 command-line download utility, you can resume and recover your previous download progress by loading a saved session file upon startup. This article explains the exact command-line flag required to import a session file, how to automatically save your sessions to prevent data loss, and provides practical examples for integrating these commands into your daily workflow.
The Core Flag:
--input-file
To tell aria2 to load a previously saved session file when it starts
up, you use the --input-file flag (or its short form,
-i).
When you pass a file to this flag, aria2 reads the list of URIs and download configurations stored within that file and adds them back into the download queue.
aria2c --input-file=session.txt(Alternatively, you can use
aria2c -i session.txt)
Setting Up a Complete Session Workflow
Simply loading a session file isn’t enough; you also need to make sure aria2 is actively saving your current progress to that same file. To create a seamless “save and resume” loop, you should combine the loading flag with the saving flag.
1. Saving the Session
(--save-session)
The --save-session flag specifies where aria2 should
output your current download progress. If aria2 is interrupted, it will
write all unfinished downloads to this file.
2. The Ideal Command Combination
To ensure that aria2 both loads your past downloads and updates them as they progress, run the command with both flags pointing to the same file path:
aria2c --input-file=session.txt --save-session=session.txtImportant Note: Before running this command for the very first time, the file (e.g.,
session.txt) must actually exist on your system, even if it is completely blank. If the file does not exist, aria2 will throw an error and refuse to start. You can create an empty file quickly using thetouch session.txtcommand on Linux/macOS ortype nul > session.txton Windows.
Automating the Process via Configuration File
If you don’t want to type these flags every time you launch the
application, you can add them to your permanent aria2 configuration file
(typically located at ~/.aria2/aria2.conf).
Add the following lines to your configuration file:
input-file=/path/to/your/session.txt
save-session=/path/to/your/session.txt
save-session-interval=60
The save-session-interval=60 option is a highly
recommended addition. By default, aria2 only saves the session file when
the program exits cleanly. Adding the interval flag forces aria2 to back
up your download state to the session file every 60 seconds, protecting
your progress even in the event of a sudden power outage or system
crash.