#!/bin/bash # up # update only if last update was more than n minutes ago n="5" # checks command -v apt >/dev/null 2>&1 || { echo "No 'apt' on this system, exiting." >&2; exit 1; } [[ -d /var/lib/apt/lists ]] || exit # action if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -cmin -"$n")" ]]; then sudo apt-get update && sudo apt-get dist-upgrade -y sudo touch /var/lib/apt/lists else echo "nope" fi