Automate Daily Downloads Using aria2c and Cron on Ubuntu
This guide explains how to schedule automatic file downloads on Ubuntu systems. By combining the lightweight downloader aria2c with the cron job scheduler, you can ensure files are retrieved at specific times without manual intervention. The following steps cover installation, script creation, and cron configuration to streamline your download workflow.
Install aria2
Open your terminal and update your package list before installing the tool. Run the following command to install aria2 on your Ubuntu machine:
sudo apt update
sudo apt install aria2Create a Download Script
You need a shell script to hold the download commands. Create a new
file in your home directory named daily-download.sh using a
text editor like nano:
nano ~/daily-download.shInside the file, add the aria2c command with the URL of the file you
wish to download. Specify the output directory using the -d
flag. Your script should look similar to this:
#!/bin/bash
aria2c -d ~/Downloads https://example.com/file.zipSave the file and exit the editor. Next, make the script executable by running:
chmod +x ~/daily-download.shConfigure the Cron Job
Open the cron table for your user to schedule the task:
crontab -eIf prompted, select your preferred text editor. Add a new line at the bottom of the file to define the schedule. The following example runs the script every day at 2:00 AM:
0 2 * * * /home/your-username/daily-download.shReplace your-username with your actual Ubuntu username.
Save and close the file. Cron will automatically install the new
job.
Verify the Automation
To ensure the cron job is active, list your current cron tasks:
crontab -lYou can also check the system logs to verify execution after the scheduled time passes. View the syslog using:
grep CRON /var/log/syslogYour files will now download automatically to the specified directory at the scheduled time each day.