Answer the question
In order to leave comments, you need to log in
Cron job not running?
I can’t figure out how to make cron work to perform file archiving and mysql database backup
tried various options
1. I made a script of this type
#!/bin/bash
echo $(date +%y%m%d)
cd /home/bitrix/ext_www/
echo "Add site web-site.ru to archive ...Start"
tar -czpf web-site_newsite.tar.gz ./web-site.ru
echo "Add site to archive ...Done!"
echo "Move archive to backup directory"
mv web-site_newsite.tar.gz /home/backup/web-site-$(date +%y%m%d).tar.gz
echo "Move archive to backup directory ...Done!"
cd /home/backup/
echo "Make backup database newshop"
mysqldump --single-transaction -u root dbweb-site > dbweb-site-$(date +%y%m%d).sql
echo "Make backup database newshop ...Done!"
cd /backup
find . -mtime +20 -exec rm {} \;
chmod +x /home/script-web.sh
18 9 * * * /home/script-web.sh
18 9 * * * root /home/script-web.sh
18 9 * * * bash /bin/bash /home/script-web.sh
23 9 * * * tar -czf /home/backup/backup_newsite.tar-$(date +%y%m%d).gz /home/bitrix/ext_www/web-site.ru > /dev/null 2>&1
#!/bin/bash
echo $(date +%y%m%d)
cd /home/bitrix/ext_www/
echo "Add site web-site.ru to archive ...Start"
tar -czpf web-site_newsite.tar.gz ./web-site.ru
echo "Add site to archive ...Done!"
echo "Move archive to backup directory"
mv web-site_newsite.tar.gz /home/backup/web-site-$(date +%y%m%d).tar.gz
echo "Move archive to backup directory ...Done!"
cd /home/backup/
echo "Make backup database newshop"
mysqldump --single-transaction -u root dbweb-site > dbweb-site-$(date +%y%m%d).sql
echo "Make backup database newshop ...Done!"
cd /backup
find . -mtime +20 -exec rm {} \;
18 9 * * * root run-parts /etc/cron.daily
Answer the question
In order to leave comments, you need to log in
The database was backed up as it should, but with a file backup of the site, its archive is obtained with a weight of 1kb
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/home/root/bin
tar -czpf /home/backup/web-site-$(date +%y%m%d).tar.gz /home/bitrix/ext_www/web-site.ru/
cd /home/backup/
mysqldump --single-transaction -u root dbweb-site > /home/backup/dbweb-site-$(date +%y%m%d).sql
in scripts launched from cron
'a, it is better to specify the full path to the utilities used,
or set the required PATH in the crontab file (or in the script itself),
because PATH cron
is very "truncated" when launched from 'a (you can check it by running in cron
'e echo $PATH > /home/.../path.log
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question