January 31, 201313 yr I' m trying to add custom job to my crontab, which as script that does a backup of mysql database: Script: backup_mysql.sh: "/usr/bin/mysqldump -u root -ppassword --all-databases > /mnt/user/Backup/MySQL/dumps/mysql_backup__`date +%Y_%m_%d_%s`.sql" Now, I run this script to add a job to crontab: crontab -l >/tmp/crontab echo "#backup mysql at 9 PM" >>/tmp/crontab echo "* 21 * * * /boot/custom/backup_mysql.sh 1> /dev/null" >>/tmp/crontab crontab /tmp/crontab cp /tmp/crontab /var/spool/cron/crontabs/root- The line is added to crontab The job executes, however it seems to be executing over and over. Once the dump file is created, another backup jobs starts. I am not sure how to fix it? I'am running unRaid 5.0-rc10
January 31, 201313 yr I'd say it is time four you to type crontab -l and post the output for analysis. I'll suspect it is not as you expect. Also, it is not necessary to copy /tmp/crontabs to /var/spool/cron/crontabs/root- I'd skip that step. (It was necessary long ago when lime-tech was storing a copy in that root- file, but in the 5.X series)
February 1, 201313 yr Author Sorry for a delay. I think I finally found a reason why this was happening. My script was missing "exit" at the end. So it should be: #! /bin/bash /usr/bin/mysqldump -u root -ppassword --all-databases > /mnt/user/Backup/MySQL/dumps/mysql_backup__`date +%Y_%m_%d_%H_%M_%S`.sql exit Once I added it at the end, the job executes only once. Attachement shows my crontab I modfied script that adds new lines to crontab: #! /bin/bash crontab -l >/tmp/crontab echo "# backup mysql at 11:30 AM" >>/tmp/crontab echo "30 11 * * * /boot/custom/mysql_dump.sh 1> /dev/null" >>/tmp/crontab echo "# tar mysql at 11:45 AM" >>/tmp/crontab echo "45 11 * * * /boot/custom/mysql_tar.sh 1> /dev/null" >>/tmp/crontab crontab /tmp/crontab exit Next I added a new line to "go" script to add new lines to crontab at boot up: # add crontab jobs /boot/custom/crontab_newline.sh But when I checked crontab -l , additions were not there. Not sure what happened? Running script from telnet works, and as you can see new lines are there.
Archived
This topic is now archived and is closed to further replies.