Search code examples
croncentosrsynctar

centos 7 backup cron issue


I have strange issue: wher i run bash script via su user /path/script.sh all work fine, but when same script running via cron, it's use all free memory and make down both servers (from and to) plus ignoring --bwlimit (i see it in control pannel of VDS).

in cron: * 10 * * * gituser /path/script.sh

my sciprt:

#!/bin/bash cd /backup

now=$(date +"%Y_%m_%d")

#mysql

mysqldump --all-databases > "$now.sql"

sshpass -p 'pass' rsync --bwlimit=5000 -rz "$now.sql" sftpuser@ip:/backup/"$now.sql"

#rm -f "$now.sql"

#for test archive

> /home/bitrix/www/testscript

echo "$now" > /path/testscript

#site files

tar cf "$now.tar" /path/. --exclude=/path/./upload --exclude=/path/./wp-content --ignore-failed-read

split --bytes=500MB "$now.tar" "$now.tar.part"

sshpass -p 'pass' rsync --bwlimit=5000 -rz "$now.tar.part"* sftpuser@ip:/backup/

#rm -f "$now.tar"

#upload files

sshpass -p 'pass' rsync --bwlimit=5000 -rz /path/upload/ sftpuser@ip:/backup/upload/

sshpass -p 'pass' rsync --bwlimit=5000 -rz /path/ sftpuser@ip:/backup/wp-content/


Solution

  • toruble was in cron time (* in minutes so its start every new minut)