LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Crontab not executing specific script (https://www.linuxquestions.org/questions/linux-general-1/crontab-not-executing-specific-script-886509/)

abdoullah 06-15-2011 10:07 AM

Crontab not executing specific script
 
Hi Guys,
I am running to a weird issue: for some reason when I try to run a crontab script which has these two operations:
#!/bin/sh
DATE=`date +%F`

mysqldump -v --opt --password=65eCom6 udb | bzip2 -9 > /home/backups/udb_mysql_$DATE.sql.bz2

smbclient \\\\vulcan35\\e -A=/root/.smb-credentials \
-c "cd Database_backup; lcd /home/backups; put udb_mysql_$DATE.sql.bz2; exit"

this script only do the sql backup but dont put it in the folder.

but when I reduce this script to the first sql backup only and I use another cron job to put this dump file to the folder it goes through...weird isn't it?
so 1+2 in 1 cronjob don't work but 1 in 1 cronjob and 2 in another cronjob it works perfect. any thoughts?

pingu 06-15-2011 12:07 PM

A first guess:
The second command is executed before the first one has finished.
Solution to that: put "&&" at the end of first command.
"mysqldump -v --opt --password=65eCom6 udb | bzip2 -9 > /home/backups/udb_mysql_$DATE.sql.bz2 &&"

abdoullah 06-15-2011 03:48 PM

Thanks! yup it was my guess also, i'll try and get back to you.

abdoullah 06-17-2011 02:15 PM

Thanks Pingu! the issue is just solved with the two magic "&&"
Thanks!


All times are GMT -5. The time now is 07:09 AM.