7

I have an script that reads some urls and get them to axel to download them. I want stop script on sometimes and resume it further. Axel can resumes file downloading. So if I press Ctrl+C when downloading, the next time, it starts from the resume of file.

but axel doesn't check that the file existed. So it appends ".0" to the end of file name and start downloding it twice. How I can tell to axel if the file with same name existed, skip that and don't downloading it??

1
  • axel uses an [FILE_NAME].st besides the main downloading file which has the state of downloaded file, if you resume it finds the state file and fetches the next bytes Mar 20, 2014 at 20:28

3 Answers 3

12

Update, some years later:

If you're using a newer axel, then please simply use the no-clobber option -c, instead of implementing it manually as described here!


If you want to make sure axel will resume, as it does per file name and not per url, you should use a deterministic name for the file:

axel -o NAME_OF_EXISTING_FILE

If you want to check if file exists

if [ -f $FILE ]; then
   echo "File $FILE exists."
    # operation related to when file exists, aka skip download
else
   echo "File $FILE does not exist." 
   # operation related to when file does not exists
fi

In case of axel, you want to start download if...

  1. You do not have that file localy, or

  2. You have a partial download, so

     function custom_axel() {
    
     local file_thingy="$1"
     local url="$2"
     if [ ! -e "$file_thingy" ]; then
         echo "file not found, downloading: $file_thingy"
         axel -avn8 "$url" -o "$file_thingy"
     elif [ -e "${file_thingy}.st" ]; then
         echo "found partial download, resuming: $file_thingy"
         axel -avn8  "$url" -o "$file_thingy"
     else
         echo "already have the file, skipped: $file_thingy"
     fi
    
     }
    

This could go into ~/.bashrc or into /usr/bin/custom_axel.sh and later:

while read URL; do
    name=$(basename "$URL") # but make sure it's valid.
    custom_axel "$name" "$URL"
done < /my/list/of/files.txt
5

Axel use a state file, named with a .st extension.
It is regularly updated during download.
When axel is started, it first checks for <file> and <file.st>. If found, download is resumed where it stopped.
Which version do you have ? I got Axel version 2.4 (Linux) and it resume correctly after a CTRL+C.

0

You can use axel with -c flag. From axel --help:

--no-clobber        -c  Skip download if file already exists

(Version 2.17.11)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.