473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Segmentation Fault on Command Line

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
6 8399
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script...
2
by: Ken Shaffer | last post by:
I am trying to install DB2 UDB 8.1 on linux. I get the segmentation fault on line 130 of db2jinst that others have mentioned. I tried: install on RH Fedora Core 2. got the seg fault error,...
11
by: Polar | last post by:
Hi! i'm a newbie in C language and i'm writing my first simple codes. In one of these, my purpose is to append the ascii value of an interger (example 101 --> e) at the end of a string to...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
1
by: Amar Prakash Tripaithi | last post by:
Hi Friends, I am working on a project of User Interface Class Library. In it, I have to create a class library in "gnu" using c++ and curses library. I am facing problem while I am on the way of...
1
by: cesco | last post by:
Hi, I'm using the boost library program_options for parsing the command line given to my program as described in the class Parameter: // Main.cpp #include "Parameter.h" using namespace std;...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
3
by: hta1984 | last post by:
i'm coding simple version of 'grep' function.i have a code which works in windows but not in linux.can you look at it and help me?: #include <stdio.h> #include <stdlib.h> #include...
14
by: cnixuser | last post by:
I am new to C programming and am still at an early level in java and C#. I am posting regarding a segmentation fault error code I get when I try to run a program that I am developing. I am coding on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.