Othello Technology Systems Ltd Community Discussion Forum

Go Back   Othello Technology Systems Ltd Community Discussion Forum > Support > OthelloHosts.net - Shared Hosting (Personal + Business)

OthelloHosts.net - Shared Hosting (Personal + Business) Help, Advice and Discussion on Shared (Virtual) Hosting Services for Home and Business users.

Reply
 
Thread Tools Display Modes
Old 15th March 2006   #1
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default error_log produced by cron job

Hi,

I've got a couple of cron jobs running on my account which do a mysqldump of my databases and then e-mail the gzipped dump to a gmail account.

The dump and gzipping etc.. is done just with some shell commands, and then a PHP script runs which sends the gzipped file as an attachment to as e-mail.

It seems to be working fine, but every time the PHP script runs, the server is logging an error in a file called error_log in my home directory.

Here's an example of what the log says:

Quote:
[15-Mar-2006 02:55:02] PHP Warning: Unknown(): Unable to load dynamic library './/usr/local/lib/php/extensions/ixed/ixed.4.4.lin' - .//usr/local/lib/php/exte
nsions/ixed/ixed.4.4.lin: cannot open shared object file: No such file or directory in Unknown on line 0
From a little googling on ixed.4.4.lin, it looks like this relates to something called sourceguardian, but other than that, I'm not too sure what's going on.

Could anyone shed any light on this? I'd ideally like the cron job to be running without buildling up an error log.

cheers,
mr_git
mr_git is offline   Reply With Quote
Old 15th March 2006   #2
Steve
StaticHost CEO
 
Join Date: Sep 2005
Location: Bristol, UK
Posts: 509
Steve will become famous soon enough
Send a message via ICQ to Steve Send a message via AIM to Steve Send a message via MSN to Steve Send a message via Yahoo to Steve
Default

Hello,

That's strange - does your script that is ran on the cronjob use SourceGuardian at all?


Regards,
__________________
[B]Steve McManus[/B]
Founder and CEO of StaticHost Internet Services
Steve is offline   Reply With Quote
Old 15th March 2006   #3
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default

Hi Steve,

yes it is odd - no my script doesn't have anything to do with SourceGuardian; it's very simple in fact, just reading the gzipped file into a variable, and then encoding up a MIME e-mail, and sending it.

I'll not post the actual script here just now, but can do later (with my personal data obscured) if it would help.

cheers,
Drew.
mr_git is offline   Reply With Quote
Old 15th March 2006   #4
Steve
StaticHost CEO
 
Join Date: Sep 2005
Location: Bristol, UK
Posts: 509
Steve will become famous soon enough
Send a message via ICQ to Steve Send a message via AIM to Steve Send a message via MSN to Steve Send a message via Yahoo to Steve
Default

Hi Drew,

Quote:
Originally Posted by mr_git
I'll not post the actual script here just now, but can do later (with my personal data obscured) if it would help.
Yeah, that should help. Does it create entries in your error_log if it's called normally via a web browser?


Regards,
__________________
[B]Steve McManus[/B]
Founder and CEO of StaticHost Internet Services
Steve is offline   Reply With Quote
Old 15th March 2006   #5
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default

Here's the script:

Code:
<?php
/* php script to be run by cron
	which sends a file (e.g. a database dump)
	as an attachment to an e-mail.

	mcdruid.co.uk 2006
	
	the following is a suggested entry to put in the crontab
	set to run shortly before this script:
	
	mysqldump -uUSERNAME -pPASSWORD --all-databases > ~/backups/daily_db_backup.sql ; gzip -f -9 ~/backups/daily_db_backup.sql

*/
	
// config variables
$account_name = "my_account";			//the *nix username of this account on the server
$target_email = "my_email@gmail.com";	//the e-mail to send this file to (gmail recommended for capacity if nothing else!)
$filename = "daily_db_backup.sql.gz";		//the file to send

// some derived settings - check that these look sensible
$path = "/home/$account_name/backups/";
$reply_to_email = "cron_$account_name@my_domain.co.uk";
$comments = "cron : $account_name : $filename";

// unique boundary (for use in the MIME e-mail)
$boundary = md5(uniqid(time));

// if the file exists, get it ready for the e-mail
if (file_exists($path. $filename))
{
	// get contents of the file to be sent into a string
	$size_of_file = filesize($path. $filename);
	$handle = fopen($path. $filename, "rb");
	$backup_file = fread($handle, $size_of_file);
	fclose($handle);
	
	$size_of_file_in_kb = round($size_of_file/1000); //see http://en.wikipedia.org/wiki/Kilobyte
	$comments .=" (". $size_of_file_in_kb. "kb)";
	
	//generate the (MIME) attachment for the e-mail
	$attachment =  "--$boundary\n" .
	   "Content-Type: application/x-gzip\n" .
	   "Content-Disposition: attachment;\n" .
	   " filename=\"{$filename}\"\n" . 
	   "Content-Transfer-Encoding: base64\n\n";
	$attachment .=  chunk_split(base64_encode("$backup_file"));
	
}
else
{
	// doesn't look like the file is there - so send a notification e-mail instead
	$comments .= "[**FAILED**] file not found";
	$attachent = ""; //no file to attach
}
	
// set up the headers for the MIME e-mail
$headers .= "X-Mailer: php\n";
$headers .= "From: cron:$account_name <$reply_to_email>";
// n.b. I use GMT - replace gmdate with just date if you just want server time
$mail_sent_date = gmdate("l jS F Y", time());		
$message = "Sent on: $mail_sent_date\r\n$comments";
$plain_text = $message;

// specify MIME version 1.0
$headers .=  "MIME-Version: 1.0\n";

// tell e-mail client this e-mail contains//alternate versions
$headers .=  "Content-Type: multipart/mixed; boundary = $boundary\n\n";

// message to people with clients who don't understand MIME
$headers .=  "This is a MIME encoded message.\n\n";

//plain text version of message
$headers .=  "--$boundary\n" .
   "Content-Type: text/plain; charset=ISO-8859-1\n" .
   "Content-Transfer-Encoding: base64\n\n";
$headers .=  chunk_split(base64_encode("$plain_text"));

//attach attachment if it's been prepared
$headers .= $attachment;


//n.b. message can then be sent like this variables:
//	mail("to address", "mail_subject", "", $headers);

mail($target_email, $comments, "", $headers);
		
?>
It's above the public_html directory, so I can't get at it in its natural habitat in a browser.

However, if I run it from the shell, it doesn't produce an error in the log.

Hmmm... interesting Mr Bond.

Any ideas Steve? I've not got a clue why this should have anything to do with SourceGuardian.

thanks,
Drew.
mr_git is offline   Reply With Quote
Old 15th March 2006   #6
Steve
StaticHost CEO
 
Join Date: Sep 2005
Location: Bristol, UK
Posts: 509
Steve will become famous soon enough
Send a message via ICQ to Steve Send a message via AIM to Steve Send a message via MSN to Steve Send a message via Yahoo to Steve
Default

Hi Drew,

I can't see what it has got to do with SourceGuardian either. What cronjob entries did you setup in cPanel?


Regards,
__________________
[B]Steve McManus[/B]
Founder and CEO of StaticHost Internet Services
Steve is offline   Reply With Quote
Old 15th March 2006   #7
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default

Hi Steve,

the cron job which runs this script is simply this:

Quote:
php backups/backup_script.php
I do have a couple of others, but they're nothing to do with PHP, and run at different times to the one in the error_log.

cheers,
Drew.
mr_git is offline   Reply With Quote
Old 15th March 2006   #8
Steve
StaticHost CEO
 
Join Date: Sep 2005
Location: Bristol, UK
Posts: 509
Steve will become famous soon enough
Send a message via ICQ to Steve Send a message via AIM to Steve Send a message via MSN to Steve Send a message via Yahoo to Steve
Default

Hi Drew,

Can you try changing it to the following?

For example, if you domain was testdomain.com, and the backup script was located at /public_html/scripts/backup_script.php, then you would use:

Let me know how it goes.
__________________
[B]Steve McManus[/B]
Founder and CEO of StaticHost Internet Services
Steve is offline   Reply With Quote
Old 15th March 2006   #9
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default

I'm happy to try that Steve, but it'll mean I have to move the script into the public_html directory obviously.

I can put the directory into which I move the script behind some auth, but I like the idea of not having it accessible to the web server at all.

Also, if I do put some auth on the directory, won't I need to pass the login credentials to lynx?

cheers,
Drew.
mr_git is offline   Reply With Quote
Old 15th March 2006   #10
mr_git
Junior Member
 
Join Date: Mar 2006
Posts: 6
mr_git is an unknown quantity at this point
Default

I've tried using lynx as you suggested Steve, and it works okay (when I put the directory behind some basic auth, it told me how to give it the credentials to get past it.)

The error hasn't been reproduced in the log.

I don't mind setting it up like this, although I would prefer not to have my script(s) in a directory the web server can see, if at all possible.

At the end of the day, I can ignore the error log as the script seems to work okay despite producing the error.

However, I would quite like to know why it's happening, and to keeop the script where it is.

I appreciate you help Steve any idea what's behind the error though?

cheers,
Drew.
mr_git is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:53.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) 2009 Othello Technology Systems Ltd