cron job failure

I have a cron job that runs weekly to back up the MySQL database & email a copy to the customer.

It runs on Monday at 3:00 AM, weekly.

It worked from September through Dec 31.

It now fails.

The host is GoDaddy; I have submitted a ticket, they claim cron jobs are fine, it's my problem with the script I'm running.

Attached are

(1) jpg of the cron job setup on GoDaddy. Not changed since Sept., 2012.

(2) php script that does the backup & emails the customer with a copy of the backup.

(3) php include file that creates the backup.

To test scripts, I ran the backup_dbase_emil.php from the browser address bar. It worked fine & created the backup file in the folder as specified. Neither of the php scripts have been changed since September.

Any ideas?
Richard KortsAsked:
Who is Participating?
Cornelia YoderConnect With a Mentor ArtistCommented:
How does it fail?   Is there an error message?  Is the backup file created?  Is an email sent?

Do you get the cron job output emailed to you?  If not, do so.

Put in some echo statements ("got to here" with numbers) right at the start and at every decision point to find out whether the script is even running, or if it fails at some specific point.

Get a better webhost with some support help.  Godaddy has the worst reputation on the internet.
how's your disk space?
Richard KortsAuthor Commented:
I'm not sure but if it runs from the browser address bar and creates a new backup file..................

I'll see if I can check.
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Richard KortsAuthor Commented:
I'm guessing the attached says using 2GB out of 10GB?
DrDamnitConnect With a Mentor Commented:
ok. That's good. next step is to check file permissions. also, check to make sure the file paths are correct.
fyi... godaddy hosting is awful. it isusually outdated, and it is always your scripts problem."
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
I get tired of people trying to blame Godaddy for their problems.  In the past 6 years with 10 web sites, both Linux and Windows, on Godaddy, I have only had two problems.  There are some issues based on their policies where they limit access in certain ways.  And their phone answer-ers aren't that knowledgeable but that doesn't make them much different than most places.

While they (and all the other hosting companies) are not perfect, the task is still finding out what is wrong.  When you do find it, Then you will know.
Cornelia YoderArtistCommented:
>>>>>>>There are some issues based on their policies where they limit access in certain ways.  And their phone answer-ers aren't that knowledgeable

You said it, I didn't.

If you want a good webhost with excellent support people, contact me privately and I'll give you one.
Richard KortsAuthor Commented:
I guess I'm not getting the point.

As I explained when I run it MANUALLY by typing in the url to the script, it works fine.

My analysis is that the scripts are fine; they execute TO COMPLETION when run manually.

The fact that it failed Jan 7 (1st Monday in 2013), seems to imply something about the year change.

Bashing GoDaddy tech support, while perhaps justifiable, is NOT getting the problem solved.
Dave BaldwinFixer of ProblemsCommented:
Like I said, I don't have any problems with Godaddy.  All hosting companies put limits on what you can do on shared hosting.  And they all have people answering the phone who are not full-fledged support engineers.

I have worked with a dozen or so web hosting companies.  The only one I really don't like is 1and1.  I don't think their phone answer-ers even know where their support engineers are.
Dave BaldwinFixer of ProblemsCommented:
Godaddy is trying to 'upgrade' all hosting to PHP 5.3.  They have had some problems with that breaking existing sites which is why most hosting companies never upgrade their existing servers.  It looks like they stopped at PHP 5.2.17 on existing hosting but PHP 5.3 is on new hosting.

I would first use '<?php' for the opening tags instead of the short tags you're using and I would make a version that turns error reporting on at the top of the script for running direct.

Did running the page in your browser also send the email?
Richard KortsAuthor Commented:

I'm not sure if it sent the email as it's Saturday & the recipient is not working & I stupidly did NOT copy myself, like I do in EVERY OTHER case like this.

I will know Monday if she got it.

I'm disinclined to change anything in the script as I'm still in a dialog with GoDaddy tech support whom I have told nothing has changed.

I thought something else might stand out to you guys.

Dave BaldwinFixer of ProblemsCommented:
Then make a copy of the script where you can make changes and maybe even add another cron job for testing.  And yes, I always (well, when I remember) 'Cc' myself on test scripts.  Godaddy is the largest hosting company in the world I believe and I usually don't wait on their tech support (or anyone else's for that matter) before I try the next thing I can figure out.  I don't mind telling someone when they get around to calling back, "Oh, I figured it out."

I had one last night where, without me knowing it, my customer's database update had failed and I couldn't use any of the test logins.  I find out this morning what happened.  I thought I had screwed it up until I realized that my test account wasn't even in the database last night.
Cornelia YoderArtistCommented:
In your copy test script, email changed to yours, put the echo statements as I told you, and see if the script is running or not.

If you get back any output you will know that the problem lies within the script.  If not, the problem is the crontab not running it.

Do you have a way to look at the actual crontab file, not the godaddy interface for it?  If so, please post it.
Cornelia YoderArtistCommented:
I notice that you have

include "backup_tables.php";

in the script and


in your code posted here.  Is this a typo, or is one of the scripts or references named incorrectly with a dash or underscore?
Richard KortsAuthor Commented:

backup_tables.php is correct; that is the name of the script file & the include.

The dash is a typo.

Cornelia YoderArtistCommented:
ok, good.  Have you done any of the other things we've asked?

Answer as many of my questions above as you can.
Copy the script to a test version with your own email.
Put echo statements into the test script and see if it is running or not.

There is, in fact, a point to mentioning the reputation of godaddy... namely that you need to narrow down where the problem lies before they are likely to be able to help you.  What Dave and I have suggested will do that.
Richard KortsAuthor Commented:
To all,

I had forgotten that I have an email sent to myself when the cron job runs; it ran last night as was scheduled.

It seems a little odd to me that it runs at 3:15 AM when it's scheduled for 3:00 AM, but that's fine.

My guess is that GoDaddy fixed the issue, then pretended there was no issue. In my years in dealing with corporate tech support types, I've found that to be common.

I have used cron job on several different Hosts, and there IS a variation in how and why the Host's tech staff sets up the "Cron Environment" for use with PHP. So if godaddy changed the Linux settings for cron-PHP (or upgraded and did-NOT change settings) then this may cause your problem? ? Anyway a Cron php is not run in the usual Apache-php environment that you have for your browser testing.
In some PHP-cron environment settings, any file paths are NOT relevant to the php file being executed, but to the PHP works (php enterpreter), so I always use complete and full file paths as in -
include "home/domain/http/cgi-bin/web/backup_tables.php";
and you might try to not use any file paths. by coping the function backup_tables() from the backup_tables.php into the cron php script. You may need to change to full path -
$fname = 'home/domain/http/dbbackups/db-backup-'.date('Y-m-d-H-i') . '.sql';
Always send your self a cron generated email with any errors, OR get output with obstart() and write a LOG FILE with a dated entry for each cron execution. I do not use godaddy at this time, but there may be a forum or user info, that you can look in for cron problems or how-to.
Dave BaldwinFixer of ProblemsCommented:
You should know that in large hosting companies, the people who answer the phone don't fix anything.  The engineering staff who you are not allowed to talk to will do any fixing and they rarely pass that info back to the phone people.

I'd be curious how many other sites on that server are running CRON jobs at 3AM.  There's good chance that you're not the only one.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.