LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 12-06-2012, 02:23 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Ubuntu Server LTS 14.04.1
Posts: 471

Rep: Reputation: 34
Thumbs down Ubuntu 12.04.1 LTS crashing on a PHP script


Hey LQ,

I have a back up machine in my house. It's a dedicated Ubuntu 12.04.1 LTS machine, it's rarely out of date in terms of software packages for longer than week.

Here is my situation. The machine regularly runs a PHP script from a cron job every day at 11pm. Sometimes this script can take up to 40 minutes to complete. This PHP backup script I've written emails me at the end of the script run so that I know the details of how the back up process went. So when I don't receive this email I know something went wrong. So far I can't seem to get the machine to back up properly for more than 3 - 5 days in a row. What ends up happening is that I lose the ability to SSH or PING the machine. I do not have a monitor connected to it.

I know that I need to learn how to write shell scripts correctly so that I'm not dependent on PHP (but hey, it's what I know as I'm a web developer and this has worked for me before on an older Ubuntu server version, and different hardware).

At any rate, I'd really love to know why the machine becomes unresponsive. Is there any kind of machine log that I could read that would tell me what is causing the machine to not respond at the network level? As far as I can tell the machine is still powered on and running but I just can't connect to it. If it really came down to it I could drag a monitor out from somewhere and plug it in but I still wouldn't know what the issue is.

Any tips or suggestions in the right direction would be great. Thanks for reading.
 
Old 12-07-2012, 05:11 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
As you seem to realise, its a question of looking at the logs, particularly (probably!) around the time of the backup process.
Start with the generic /var/log/messages.

Also, you should add some checking and debug logging to your script.
Unfortunately, I don't know PHP, so I can't be specific, but if you were using eg bash, you could check the success/failure of each cmd by checking the completion status stored in the shell var $?.
I'm guessing PHP has a similar ability.
Get it to log this at each stage.

A wild guess(!) says it could be running out of disk space during the backup. A lot of backup type operations use a lot of tmp space in the background (eg gzip etc).

HTH

PS Re bash scripting
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

and start a bash script with
Code:
#!/bin/bash
# debug; tell parser to show everything it does
set -xv
 
Old 12-07-2012, 08:28 PM   #3
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Ubuntu Server LTS 14.04.1
Posts: 471

Original Poster
Rep: Reputation: 34
Quote:
Originally Posted by chrism01 View Post
As you seem to realise, its a question of looking at the logs, particularly (probably!) around the time of the backup process.
Start with the generic /var/log/messages.

Also, you should add some checking and debug logging to your script.
Unfortunately, I don't know PHP, so I can't be specific, but if you were using eg bash, you could check the success/failure of each cmd by checking the completion status stored in the shell var $?.
I'm guessing PHP has a similar ability.
Get it to log this at each stage.

A wild guess(!) says it could be running out of disk space during the backup. A lot of backup type operations use a lot of tmp space in the background (eg gzip etc).

HTH

PS Re bash scripting
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

and start a bash script with
Code:
#!/bin/bash
# debug; tell parser to show everything it does
set -xv
Thanks for the tips! The script builds a huge tarchive (2gb with 10's of thousands of files and directories). The harddrive is only 80gb so I wonder if it's running out of swap space or something? I'll check into those logs and report back.
 
Old 12-07-2012, 08:32 PM   #4
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Ubuntu Server LTS 14.04.1
Posts: 471

Original Poster
Rep: Reputation: 34
Here is the ls of my /var/log dir. Where do you suppose I start looking first?

Code:
wh33t@wh33tserv:/var/log$ ls
alternatives.log       dmesg.1.gz      mail.err        mysql.log.7.gz
alternatives.log.1     dmesg.2.gz      mail.err.1      news
alternatives.log.2.gz  dmesg.3.gz      mail.err.2.gz   syslog
alternatives.log.3.gz  dmesg.4.gz      mail.err.3.gz   syslog.1
apache2                dpkg.log        mail.err.4.gz   syslog.2.gz
apt                    dpkg.log.1      mail.log        syslog.3.gz
auth.log               dpkg.log.2.gz   mail.log.1      syslog.4.gz
auth.log.1             dpkg.log.3.gz   mail.log.2.gz   syslog.5.gz
auth.log.2.gz          faillog         mail.log.3.gz   syslog.6.gz
auth.log.3.gz          fontconfig.log  mail.log.4.gz   syslog.7.gz
auth.log.4.gz          fsck            mysql           udev
boot                   installer       mysql.err       ufw.log
boot.log               kern.log        mysql.log       unattended-upgrades
btmp                   kern.log.1      mysql.log.1.gz  upstart
btmp.1                 kern.log.2.gz   mysql.log.2.gz  wtmp
ConsoleKit             kern.log.3.gz   mysql.log.3.gz  wtmp.1
dist-upgrade           kern.log.4.gz   mysql.log.4.gz
dmesg                  landscape       mysql.log.5.gz
dmesg.0                lastlog         mysql.log.6.gz

Last edited by wh33t; 12-07-2012 at 08:32 PM. Reason: quote to code
 
  


Reply

Tags
12.04 lts, backup, cron, php, ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu 12.04 LTS 64-bit crashing on Macbook Pro 7.1 coolbeans777 Ubuntu 0 08-04-2012 07:22 PM
LXer: Ubuntu 12.04 LTS KVM Virtualization Battles 8.04.4, 10.04.4 LTS LXer Syndicated Linux News 0 04-09-2012 12:40 PM
Script run at startup doesn't work under Ubuntu 10.04 LTS DSchuler Linux - Newbie 6 05-03-2011 08:42 PM
No enough space error when trying upgrade ubuntu from 8.04 lts to 10.04 lts flik shen Ubuntu 5 06-15-2010 01:44 PM
LXer: I update Ubuntu 6.06 LTS and 8.04 LTS ... one has SSH issues, one does not LXer Syndicated Linux News 0 05-20-2008 08:30 AM


All times are GMT -5. The time now is 03:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration