I am attempting to alter an existing cronjob bash script someone previously in my position wrote. It seems to be working fine, other than the amount of resources it is consuming. Limiting pigz to half my cores doesn't seem to be having an effect. When the script is ran and I monitor the server with top or htop, i see several iteration of tar and pigz running and they use almost 100% of my cores and memory. I have not been able to find any helpful information on how to prevent this from happening.
# Assign value to "TODAY" so that it doesn't change after midnight during script execution.
TODAY=$(date +"%Y%m%d")
# Identifies the week of the month. This is used for automated removal of outdated backups.
WEEKNUMBER=$(expr $(expr $(expr $(date +%d) - 1) / 7 ) + 1)
# Create new folder for tar and log files
LOGFILES=/home/scripts/BUScripts/TestMem/logs/VM_Test_fullbu_$TODAY
TARFILES=/home/scripts/BUScripts/TestMem/VM_Test_fullbu_$TODAY
SOURCEFILES=/
tar --ignore-failed-read -I pigz -cvpf $TARFILES/$p"_fullbu_"$TODAY.$WEEKNUMBER.tar $SOURCEFILES/$p >>
$LOGFILES/$p"_fullbu_"$TODAY.txt 2>&1 && echo $p" full backup completed successfully at $(date)." >>
$LOGFILES//$p"_fullbu_"$TODAY.txt || echo $p" full backup completed with error at $(date)." >>
$LOGFILES/$p"_fullbu_"$TODAY.txt &