Skip to content

Instantly share code, notes, and snippets.

@gayanvirajith
Created May 8, 2020 03:47
Show Gist options
  • Save gayanvirajith/665febcc1e4e22f41663e489c5e143cc to your computer and use it in GitHub Desktop.
Save gayanvirajith/665febcc1e4e22f41663e489c5e143cc to your computer and use it in GitHub Desktop.
shell script with dot output | progress bar
# progressdots.sh - Display progress while making backup
# Based on idea presnted by nixCraft forum user rockdalinux
# Show progress dots
# Credit: https://bash.cyberciti.biz/guide/Putting_functions_in_background
progress(){
echo -n "$0: Please wait..."
while true
do
echo -n "."
sleep 5
done
}
dobackup(){
# put backup commands here
tar -zcvf /dev/st0 /home >/dev/null 2>&1
}
# Start it in the background
progress &
# Save progress() PID
# You need to use the PID to kill the function
MYSELF=$!
# Start backup
# Transfer control to dobackup()
dobackup
# Kill progress
kill $MYSELF >/dev/null 2>&1
echo -n "...done."
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment