Results 1 to 4 of 4

Thread: Retry logic through apt-get

  1. #1
    Join Date
    Sep 2014
    Beans
    2

    Retry logic through apt-get

    Folks,

    I need help please to implement the retry logic through apt-get tool. Here is the scenario.

    1-Try to deploy package
    2-If it succeed, we process the next instruction.
    3-If it fails, retry within 60sec.
    4- stop retrying after 30mins, and log errors.

    Anyone can confirm that the below script works as expected

    while ! echo y | sudo apt-get install lamp-server^ &> /home/azureuser/aptlamp.log
    do
    sleep 60
    sudo apt-get install lamp-server^ &> /home/azureuser/aptlamp.log
    done

    Thanks,

  2. #2
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,952

    Re: Retry logic through apt-get

    If an apt action fails, it fails for a reason.
    Retrying before addressing the reason seems like wasted effort.

  3. #3
    Join Date
    Sep 2014
    Beans
    2

    Re: Retry logic through apt-get

    could be any temporary network/DNS issue, that goes away after few seconds.

  4. #4
    Join Date
    Jul 2013
    Location
    Wisconsin
    Beans
    4,952

    Re: Retry logic through apt-get

    Will retrying apt for 30 minutes work? Sure it will. But it seems an inelegant solution to me.
    Test your network access (ping) or DNS (dig) before starting the package manager.
    The package manager can, at various times, be a heavy user of disk IO, CPU, memory, and network bandwidth.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •