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@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@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@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@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@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@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@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 Sun, Jul 31, 2011 at 03:19:01PM +1200, Cliff Pratt wrote:
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').
Only execs outside of /bin:/usr/bin need to be fully pathed; cron exports a default PATH of /bin:/usr/bin.
Please see "man crontab" for the explanation as to what is going wrong here; look for '%' in the man page.
John
On Sun, Jul 31, 2011 at 3:31 PM, John R. Dennison jrd@gerdesas.com wrote:
On Sun, Jul 31, 2011 at 03:19:01PM +1200, Cliff Pratt wrote:
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').
Only execs outside of /bin:/usr/bin need to be fully pathed; cron exports a default PATH of /bin:/usr/bin.
Please see "man crontab" for the explanation as to what is going wrong here; look for '%' in the man page.
Ah! I never knew that! It's a good trap.
Cheers,
Cliff
On Sun, 31 Jul 2011, Cliff Pratt wrote:
To: CentOS mailing list centos@centos.org From: Cliff Pratt enkiduonthenet@gmail.com Subject: Re: [CentOS] cron jobs not running
On Sun, Jul 31, 2011 at 3:31 PM, John R. Dennison jrd@gerdesas.com wrote:
On Sun, Jul 31, 2011 at 03:19:01PM +1200, Cliff Pratt wrote:
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').
Only execs outside of /bin:/usr/bin need to be fully pathed; cron exports a default PATH of /bin:/usr/bin.
Please see "man crontab" for the explanation as to what is going wrong here; look for '%' in the man page.
Ah! I never knew that! It's a good trap.
Greetings all!
Cliff - you might like to check out my customizable mysql database backup script (PHP5 CLI code) at:
http://forums.fedoraforum.org/showpost.php?p=1499959&postcount=3
Use at your own risk of course!
Kind Regards,
Keith Roberts
----------------------------------------------------------------- Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk
All email addresses are challenge-response protected with TMDA [http://tmda.net] -----------------------------------------------------------------
On Sun, 31 Jul 2011, Keith Roberts wrote:
Woops! I meant Tim the OP - not Cliff :)
Cliff - you might like to check out my customizable mysql database backup script (PHP5 CLI code) at:
http://forums.fedoraforum.org/showpost.php?p=1499959&postcount=3
Kind Regards,
Keith Roberts
----------------------------------------------------------------- Websites: http://www.karsites.net http://www.php-debuggers.net http://www.raised-from-the-dead.org.uk
All email addresses are challenge-response protected with TMDA [http://tmda.net] -----------------------------------------------------------------
On 07/30/2011 11:07 PM, Tim Dunphy wrote:
0 3 * * * /bin/alldb > /home/bluethundr/backupdb/alldb-$(date +%Y%m%d%H%S).sql
I 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.
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@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.