hello list!! I'm attempting to find out why this cron job isn't running. the host is centos 5.6 on i386 just so you know. 0 3 * * * /bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql The job is meant to backup all the databases on a mysql server every day at 3 am. I have checked the backup directory and nothing is showing up for those days. I created the same job to run every minute but just like the job above the backups do not appear. * * * * * /bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql I have verified that the cron service is, indeed, running [root at VIRTCENT09:/home/bluethundr/backupdb] #service crond status crond (pid 8053) is running... However I do see the job is running in the cron logs [root at VIRTCENT09:/home/bluethundr/backupdb] #tail /var/log/cron Jul 30 22:59:01 VIRTCENT09 crond[8007]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Jul 30 22:59:46 VIRTCENT09 crond[8053]: (CRON) STARTUP (V5.0) Jul 30 23:00:01 VIRTCENT09 crond[8074]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Jul 30 23:00:10 VIRTCENT09 crontab[8121]: (root) BEGIN EDIT (root) Jul 30 23:01:01 VIRTCENT09 crond[8134]: (root) CMD (run-parts /etc/cron.hourly) Jul 30 23:01:01 VIRTCENT09 crond[8135]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Jul 30 23:02:01 VIRTCENT09 crond[8157]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Jul 30 23:03:02 VIRTCENT09 crond[8265]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Jul 30 23:03:13 VIRTCENT09 crontab[8121]: (root) END EDIT (root) Jul 30 23:04:01 VIRTCENT09 crond[8288]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +) Still nothing is appearing in the backup directory. But if i run the command by hand it does work. [root at VIRTCENT09:/home/bluethundr/backupdb] #/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql And the file is created:
On Sun, Jul 31, 2011 at 3:07 PM, Tim Dunphy <bluethundr at jokefire.com> wrote:> hello list!! > > I'm attempting to find out why this cron job isn't running. the host is centos 5.6 on i386 just so you know. > > > 0 ? ? ? 3 ? ? ? * ? ? ? * ? ? ? * ? ? ? /bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql > > The job is meant to backup all the databases on a mysql server every day at 3 am. I have checked the backup directory and nothing is showing up for those days. > > I created the same job to run every minute but just like the job above the backups do not appear. > > > * ? ? ? * ? ? ? * ? ? ? * ? ? ? * /bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql > > > I have verified that the cron service is, indeed, running > > [root at VIRTCENT09:/home/bluethundr/backupdb] #service crond status > crond (pid ?8053) is running... > > > However I do see the job is running in the cron logs > > > [root at VIRTCENT09:/home/bluethundr/backupdb] #tail /var/log/cron > Jul 30 22:59:01 VIRTCENT09 crond[8007]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > Jul 30 22:59:46 VIRTCENT09 crond[8053]: (CRON) STARTUP (V5.0) > Jul 30 23:00:01 VIRTCENT09 crond[8074]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > Jul 30 23:00:10 VIRTCENT09 crontab[8121]: (root) BEGIN EDIT (root) > Jul 30 23:01:01 VIRTCENT09 crond[8134]: (root) CMD (run-parts /etc/cron.hourly) > Jul 30 23:01:01 VIRTCENT09 crond[8135]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > Jul 30 23:02:01 VIRTCENT09 crond[8157]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > Jul 30 23:03:02 VIRTCENT09 crond[8265]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > Jul 30 23:03:13 VIRTCENT09 crontab[8121]: (root) END EDIT (root) > Jul 30 23:04:01 VIRTCENT09 crond[8288]: (root) CMD (/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +) > > Still nothing is appearing in the backup directory. > > But if i run the command by hand it does work. > > [root at VIRTCENT09:/home/bluethundr/backupdb] #/bin/alldb ?> /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql > > And the file is created: >Tim, the program is run by cron in a different environment to the standard online environment. Is /bin/alldb a script? If so, *any* program in the script should have a full path, or the PATH enviroment variable should be specified in the cron. (see 'man cron'). You could try redirecting all STDERR output to a file (2>filename) to see if any errors are produced. Cheers, Cliff
On 07/30/2011 11:07 PM, Tim Dunphy wrote:> 0 3 * * * /bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sqlI think the date paremters (percent etc) is causing you problems here. Try it simple first: * * * * * /bin/alldb > /home/bluethundr/backupdb/alldb-today.sql Did it work? -- Jorge
Hello Tim, On Sun, 2011-07-31 at 03:07 +0000, Tim Dunphy wrote:> * * * * * /bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql> Jul 30 22:59:01 VIRTCENT09 crond[8007]: (root) CMD (/bin/alldb > /home/bluethundr/backupdb/alldb-$(date +)Think you need to quote that date format string, and I suppose the last field is supposed to be %M not %S. Also, since "date +" resolves to "" the command as it is currently interpreted will write to the same file (/home/bluethundr/backupdb/alldb-) over and over again. Regards, Leonard. -- mount -t life -o ro /dev/dna /genetic/research
On 07/30/2011 10:07 PM, Tim Dunphy wrote:> hello list!! > > I'm attempting to find out why this cron job isn't running. the host is centos 5.6 on i386 just so you know. > > > 0 3 * * * /bin/alldb> /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql> However I do see the job is running in the cron logs > > > [root at VIRTCENT09:/home/bluethundr/backupdb] #tail /var/log/cron > Jul 30 22:59:01 VIRTCENT09 crond[8007]: (root) CMD (/bin/alldb> /home/bluethundr/backupdb/alldb-$(date +)From `man 5 crontab`: The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL vari- able of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.