Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cron job failure

Posted on 2013-01-12
20
Medium Priority
?
748 Views
Last Modified: 2013-01-14
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?
godaddy-cron.jpg
backup-dbase-email.php
backup-tables.php
0
Comment
Question by:Richard Korts
  • 6
  • 5
  • 5
  • +2
20 Comments
 
LVL 32

Expert Comment

by:DrDamnit
ID: 38770548
how's your disk space?
0
 

Author Comment

by:Richard Korts
ID: 38770582
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.
0
 

Author Comment

by:Richard Korts
ID: 38770588
I'm guessing the attached says using 2GB out of 10GB?
tchristy-acct-snapshot.jpg
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
LVL 32

Assisted Solution

by:DrDamnit
DrDamnit earned 200 total points
ID: 38770596
ok. That's good. next step is to check file permissions. also, check to make sure the file paths are correct.
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 38770600
fyi... godaddy hosting is awful. it isusually outdated, and it is always your scripts problem."
0
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 900 total points
ID: 38770601
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.
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 900 total points
ID: 38770629
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.
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 38770774
>>>>>>>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.
0
 

Author Comment

by:Richard Korts
ID: 38770790
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.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38770805
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.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38770821
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?
0
 

Author Comment

by:Richard Korts
ID: 38770833
DaveBaldwin

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.

Richard
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38770879
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.
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 38770939
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.
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 38770943
I notice that you have

include "backup_tables.php";

in the script and

backup-tables.php

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

Author Comment

by:Richard Korts
ID: 38772311
yodercm

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

The dash is a typo.

Thanks
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 38772678
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.
0
 

Author Comment

by:Richard Korts
ID: 38774799
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.

rkorts
0
 
LVL 34

Expert Comment

by:Slick812
ID: 38775004
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.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 38775244
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.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to dynamically set the form action using jQuery.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question