How to automatically update Atom editor?

TL;DR If you do not want to use the PPA, you can use a script to download and automatically install via cron.


  1. Create a new file atom-auto-update

    sudo nano /usr/local/bin/atom-auto-update
    
  2. Add the following lines

    #!/bin/bash
    wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
    wget -q $(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest) -O /tmp/atom-amd64.deb
    dpkg -i /tmp/atom-amd64.deb
    
  3. Save the file and make it executable

    sudo chmod +x /usr/local/bin/atom-auto-update
    
  4. Test the script

    sudo atom-auto-update
    
  5. Create a cronjob for the script

    sudo crontab -e
    
  6. Add this line

    e.g.: at 10 am every week

    0 10 * * 1 /usr/local/bin/atom-auto-update
    

    e.g.: at 10 am every day

    0 10 * * * /usr/local/bin/atom-auto-update      
    

Explanation

  • wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest

    Download the site with the latest version information

  • wget -q $(awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest) -O /tmp/atom-amd64.deb

    1. … awk -F '[<>]' '/href=".*atom-amd64.deb/ {match($0,"href=\"(.*.deb)\"",a); print "https://github.com/" a[1]} ' /tmp/latest …

      Extract the download link

    2. wget -q $( … ) -O /tmp/atom-amd64.deb

      Download the DEB file

  • dpkg -i /tmp/atom-amd64.deb

    Install the DEB file


A.B's Answer is a nice solution! I added show progress bar option in the bash code to notify progress: 

#!/bin/bash
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
wget --progress=bar -q 'https://github.com'$(cat /tmp/latest | grep -o -E 'href="([^"#]+)atom-amd64.deb"' | cut -d'"' -f2 | sort | uniq) -O /tmp/atom-amd64.deb -q --show-progress
dpkg -i /tmp/atom-amd64.deb

As the previous answer with minor modification, to let updating on start-up, here is the procedure

  1. Create file by running the command:

    sudo nano /usr/local/bin/atom-update  
    

then type the below script (use text-editor like "gedit" or "mousepad" instead of "nano" is more convenient) and then save it.

#!/bin/bash    
wget -q https://github.com/atom/atom/releases/latest -O /tmp/latest
MATCHEDROW=$(awk -F '[<>]' '/href=".*atom-amd64.deb/' /tmp/latest)
LATEST=$(echo $MATCHEDROW | grep -o -P '(?<=href=").*(?=" rel)')
VER_LATEST=$(echo $MATCHEDROW | rev | cut -d"/" -f 2 | rev | sed 's/v//g')
VER_INST=$(dpkg -l atom | tail -n1 | tr -s ' ' | cut -d" " -f 3)

if [ "$VER_LATEST" != "$VER_INST" ]; then
   wget --progress=bar -q "https://github.com/$LATEST" -O /tmp/atom-amd64.deb --show-progress
   dpkg -i /tmp/atom-amd64.deb
   echo "Atom has been update from $VER_LATEST to $VER_INST"
   logger -t atom-update "Atom has been update from $VER_INST to $VER_LATEST"
else
   echo "Atom version $VER_INST is the latest version, no update require"
   logger -t atom-update "Atom version $VER_INST is the latest version, no update require"
fi
  1. To make the file executable:

    sudo chmod +x /usr/local/bin/atom-update
    
  2. Now you could manually update Atom by typing the command:

    sudo atom-update
    
  3. Login to your root, and then add the below row to /etc/rc.local (sudo nano /etc/rc.local) just before exit 0 command:

    /usr/local/bin/atom-update  
    

This will let the atom update script execute every time you turn on your PC.

  1. To check that the script has run properly on start up, restart your PC and open the terminal then type:

    cat /var/log/syslog | grep 'atom.*'  
    

You will see the log message accordingly.

Tags:

Updates

Atom