By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,776 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,776 IT Pros & Developers. It's quick & easy.

Segmentation Fault on Command Line

P: n/a
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not succeeding
and ran it manually from the command line and it threw a Segmentation Fault.

Googling produces a ton of information on this subject but al of specific to
certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.

TIA,

jg

<?
mysql_connect('mysql.example.com', 'example', 'example');
mysql_select_db('example');
mysql_query("DELETE FROM aniSessionLog WHERE timestamp < NOW() - 900");
$rows = mysql_affected_rows();
mail('j*@example.com', 'cleaned Intranet DB', "$rows rows deleted.");
?>
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
jerrygarciuh wrote:
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not succeeding
and ran it manually from the command line and it threw a Segmentation
Fault.

Googling produces a ton of information on this subject but al of specific
to certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.


I wouldn't expect a script to produce a segmentation fault - more likely to
be a change/fault in the binaries somewhere (particularly if you are using
mod_php in your webserver). Try some different stuff from the CLI to find
the fault, meanwhile use wget / curl to run the script via the webserver.

HTH

C.
Jul 17 '05 #2

P: n/a
jerrygarciuh wrote:
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not succeeding
and ran it manually from the command line and it threw a Segmentation Fault.

Googling produces a ton of information on this subject but al of specific to
certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.

TIA,

jg

<?
mysql_connect('mysql.example.com', 'example', 'example');
mysql_select_db('example');
mysql_query("DELETE FROM aniSessionLog WHERE timestamp < NOW() - 900");
$rows = mysql_affected_rows();
mail('j*@example.com', 'cleaned Intranet DB', "$rows rows deleted.");
?>


One thought here - are you using the same version of PHP in both cases?
Perhaps you updated PHP - but left the old one as the default binary.
To find out, run php -v from the command line and use phpinfo() from
the web server.

The only other thing I can think of is if the user the cron job is
running under doesn't have permissions for mysql or mail access.

Try commenting out the mail() call to see if that does it. If not, work
back, commenting out statements until it works (or until nothing is left
- in which case the connect has problems).

BTW - you could also close the connection when you're done. It's
cleaner than letting the system clean up for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #3

P: n/a
Thanks, will do!

jg
"Jerry Stuckle" <js*******@attglobal.net> wrote in message
news:Cs********************@comcast.com...
jerrygarciuh wrote:
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not
succeeding and ran it manually from the command line and it threw a
Segmentation Fault.

Googling produces a ton of information on this subject but al of specific
to certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.

TIA,

jg

<?
mysql_connect('mysql.example.com', 'example', 'example');
mysql_select_db('example');
mysql_query("DELETE FROM aniSessionLog WHERE timestamp < NOW() -
900");
$rows = mysql_affected_rows();
mail('j*@example.com', 'cleaned Intranet DB', "$rows rows deleted.");
?>


One thought here - are you using the same version of PHP in both cases?
Perhaps you updated PHP - but left the old one as the default binary. To
find out, run php -v from the command line and use phpinfo() from the web
server.

The only other thing I can think of is if the user the cron job is running
under doesn't have permissions for mysql or mail access.

Try commenting out the mail() call to see if that does it. If not, work
back, commenting out statements until it works (or until nothing is left -
in which case the connect has problems).

BTW - you could also close the connection when you're done. It's cleaner
than letting the system clean up for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 17 '05 #4

P: n/a
Thanks, this will prove a good opportunity to explore curl!

jg
"Colin McKinnon" <co**************@andthis.mms3.com> wrote in message
news:d5*******************@news.demon.co.uk...
jerrygarciuh wrote:
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not
succeeding
and ran it manually from the command line and it threw a Segmentation
Fault.

Googling produces a ton of information on this subject but al of specific
to certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.


I wouldn't expect a script to produce a segmentation fault - more likely
to
be a change/fault in the binaries somewhere (particularly if you are using
mod_php in your webserver). Try some different stuff from the CLI to find
the fault, meanwhile use wget / curl to run the script via the webserver.

HTH

C.

Jul 17 '05 #5

P: n/a
Bizarrely this comand

/usr/local/bin/php -q /home/u4/somePath/html/auth/dbclean.php

Produces

Segmentation fault

Even when the whole script is

<?
// nothing to do
?>

The phpinfo() and php -v check produced the same build date and version
info.

Also strange is the discovery that when run manually via command line it
still clears rows AND send email despite segmentation fault. When run by
cron job, the email arrives but the rows have not been deleted.

Thanks for your time and help with this!

jg

"Jerry Stuckle" <js*******@attglobal.net> wrote in message
news:Cs********************@comcast.com...
jerrygarciuh wrote:
Hello,

I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not
succeeding and ran it manually from the command line and it threw a
Segmentation Fault.

Googling produces a ton of information on this subject but al of specific
to certain binaries and it doesn't seem germaine to solving my problem.

Any one have any advice? Whole script is below.

TIA,

jg

<?
mysql_connect('mysql.example.com', 'example', 'example');
mysql_select_db('example');
mysql_query("DELETE FROM aniSessionLog WHERE timestamp < NOW() -
900");
$rows = mysql_affected_rows();
mail('j*@example.com', 'cleaned Intranet DB', "$rows rows deleted.");
?>


One thought here - are you using the same version of PHP in both cases?
Perhaps you updated PHP - but left the old one as the default binary. To
find out, run php -v from the command line and use phpinfo() from the web
server.

The only other thing I can think of is if the user the cron job is running
under doesn't have permissions for mysql or mail access.

Try commenting out the mail() call to see if that does it. If not, work
back, commenting out statements until it works (or until nothing is left -
in which case the connect has problems).

BTW - you could also close the connection when you're done. It's cleaner
than letting the system clean up for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 17 '05 #6

P: n/a
jerrygarciuh wrote:
Bizarrely this comand

/usr/local/bin/php -q /home/u4/somePath/html/auth/dbclean.php

Produces

Segmentation fault

Even when the whole script is

<?
// nothing to do
?>

The phpinfo() and php -v check produced the same build date and version
info.

Also strange is the discovery that when run manually via command line it
still clears rows AND send email despite segmentation fault. When run by
cron job, the email arrives but the rows have not been deleted.

Thanks for your time and help with this!

jg


Interesting. Have you checked your PHP installation? It sounds like
something might be wrong with the php binary file. You might also check
the php bugs list for your version to see if there's anything.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.