Author Topic: Cron issue  (Read 2787 times)

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Cron issue
« on: August 08, 2012, 03:51:50 AM »
Go figure i busted obes balls now I have an issue. I wrote a cron php file to backup one of my mysql db's. I am testing it at the command line using php myfile.php. It is executing, but is not saving the entire DB. This DB is close to 65MB, yet the file size after running the script is only 203k.

Any ideas as to why?

Code minus sensitive data.

Code: [Select]
<?php
$u 
'XXXXXX';
$p 'XXXXXX';
$d 'XXXXXX';
$x'mysqldump --no-create-db=true -S /*****/tmp/mysql5.sock -u $u -p $p $d > ******.sql';
system($x);
?>
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Cron issue
« Reply #1 on: August 08, 2012, 08:30:20 AM »
Well, what is in the file it dumps?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #2 on: August 08, 2012, 08:48:02 AM »
Didnt look. I will check it and report back
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #3 on: August 08, 2012, 05:32:15 PM »
Sorry long day. Contents are

Quote

Usage: mysqldump [OPTIONS] database [tables]
OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
For more options, use mysqldump --help
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Cron issue
« Reply #4 on: August 08, 2012, 05:40:12 PM »
Well there's your problem.

As a reference, here is our backup's command:
Code: [Select]
/usr/local/bin/mysqldump --password=<PASSWORD> --allow-keywords --quote-names --opt --master-data=1 --database <DATABASE> -S /tmp/mysql.sock ><DUMPFILE>

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #5 on: August 08, 2012, 07:56:57 PM »
Yea but this is the backup line that works perfectly right in the shell. In fact on my host it is the only command that will dump the DB. So it's the command I need to execute in cron, and i checked and it is working outside of the php file.
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Cron issue
« Reply #6 on: August 08, 2012, 11:04:29 PM »
Why are you using the php file at all?  Just put the command directly in the cron.  What you're doing is overkill.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #7 on: August 08, 2012, 11:43:15 PM »
Just what I was taught I guess. Every cron I have ever set is in a php file. So I can actully just do:

00 4 * * 0 mysqldump --no-create-db=true -S /*****/tmp/mysql5.sock -u user -p password dbname > savename.sql

And it will run correctly every sunday at 4am?
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

Mike

  • Jackass In Charge
  • Posts: 11257
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Cron issue
« Reply #8 on: August 09, 2012, 12:09:09 AM »
It is generally a good idea to give the full path to commands.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #9 on: August 09, 2012, 01:15:01 AM »
in this case it is, I'm just editing it since this is public view
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

ober

  • Ashton Shagger
  • Ass Wipe
  • Posts: 14310
  • Karma: +73/-790
  • mini-ober is taking over
    • Windy Hill Web Solutions
Re: Cron issue
« Reply #10 on: August 09, 2012, 09:20:19 AM »
Not sure about the way you set it up directly from command line.  I always do mine through cpanel.  But yeah, you just put all the details in the actual cron line.

Steve

  • This 49%er supports Romney
  • Just a Jackass
  • *
  • Posts: 16120
  • Karma: +31/-410
  • Mr. Mom
Re: Cron issue
« Reply #11 on: August 09, 2012, 04:22:53 PM »
Thanks ober, will give it a try
hey ethic if you and i were both courting lily allen..... oh wait, which one of us has a relationship that lasted more than the bus ride home?

webwhy

  • Jackass IV
  • Posts: 608
  • Karma: +15/-10
Re: Cron issue
« Reply #12 on: August 10, 2012, 04:46:28 PM »
how does this work with a single quoted PHP string ($x)?  Your variables will not interpolate.