Skip to content

Instantly share code, notes, and snippets.

@solrevdev
Created August 15, 2022 21:10
Show Gist options
  • Select an option

  • Save solrevdev/6060bb2f0568b3e85101e72a9b4f1a97 to your computer and use it in GitHub Desktop.

Select an option

Save solrevdev/6060bb2f0568b3e85101e72a9b4f1a97 to your computer and use it in GitHub Desktop.
Runs apt-get update, upgrade and autoremove commands with elapsed time written to console
#!/bin/bash
# store the current date into a variable called startTime
startTime=$(date +"%s")
echo "Start time: $(date)"
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get autoremove -y
finishTime=$(date +"%s")
echo "End time: $(date)"
# write out how long script took to run
diff=$(($finishTime-$startTime))
echo "$(($diff / 3600)) hours, $((($diff / 60) % 60)) minutes and $(($diff % 60)) seconds elapsed."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment