I have two shell script named: backup_inventory_sourcecode.sh
and backup_bash.sh
. I run these two .sh file using as putty as follows:
sh /var/www/html/backup_inventory_sourcecode.sh
sh /var/www/html/backup_bash.sh
it runs successfully and created a zip file and sql file file respectively. The content of backup_inventory_sourcecode.sh is:
#!/bin/bash
NOW=$(date +"%m_%d_%Y")
sudo zip -r /inventory_sourcecode_backup/inventory_backup_${NOW}.zip /var/www/html/inventory -x ".git"
sync
/var/www/html/ftpupload.sh /inventory_sourcecode_backup/inventory_backup_${NOW}.zip
and content of backup_bash.sh is:
#!/bin/bash
NOW=$(date +"%m_%d_%Y_%H_%M_%S")
NOW=${NOW}_Inventory
mysqldump -u root -pAplrootuser db_apl_inventory >/db_backup/${NOW}.sql
#sleep 30
/var/www/html/ftpupload.sh /db_backup/${NOW}.sql
Now I put the two lines in crontab:
*/1 * * * * sh /var/www/html/backup_inventory_sourcecode.sh
*/1 * * * * sh /var/www/html/backup_bash.sh
these should create .zip and .sql file respectively. but it produce only .sql file. It proves only */1 * * * * sh /var/www/html/backup_bash.sh
works but not */1 * * * * sh /var/www/html/backup_inventory_sourcecode.sh
. What is the problem.
Путь Cron по умолчанию зависит от реализации, поэтому проверьте свою страницу руководства.
Вы можете определить свою собственную переменную PATH
в вашем файле crontab.
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
*/1 * * * * sh /var/www/html/backup_inventory_sourcecode.sh
*/1 * * * * sh /var/www/html/backup_bash.sh