0

I execute a sh script in terminal which backs up some folders. However, these folders are contained within the /var/www/ directory. I use sudo -i to access this directory but when it's executed in the terminal, the terminal switches to root user and the script pauses. The script will continue when I exit the root.

Is it possible to use root in the script without it pausing in the terminal?

#!/bin/sh
echo -n "Backing up files..."
sudo -i
cd /var/www/myFolder/
tar -czvf "/home/userName/Documents/Backup_files.tar.gz"
echo -e "\rBacking up files...100%"
exit
jim
  • 1

0 Answers0