FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » cron job and headers sent error
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: cron job and headers sent error [message #182774 is a reply to message #182771] Mon, 09 September 2013 02:21 Go to previous messageGo to previous message
T0xicCode is currently offline  T0xicCode
Messages: 2
Registered: September 2013
Karma:
Junior Member
On 13-09-08 04:30 PM, J.O. Aho wrote:
> On 08/09/13 17:35, Richard Yates wrote:
>> On Sun, 08 Sep 2013 16:40:30 +0200, "J.O. Aho" <user(at)example(dot)net>
>> wrote:
>>
>>> On 08/09/13 15:36, Richard Yates wrote:
>>>> I have a script that runs automatically every night that shortens some
>>>> tables. It has been working fine (Actually still is doing what it is
>>>> supposed to). However I started getting an email warning notice when
>>>> it runs. In says headers have already been sent in line two of the
>>>> database Connection script that is included. I cannot figure out how
>>>> anything is being sent. The connection script does not output
>>>> anything. Line 2 identifies whether the script is running on the local
>>>> or production server. Any ideas where the error is coming from? Here
>>>> are the warning message, the cron script and the included connection
>>>> script:
>>>>
>>>> -------- warning notice
>>>>
>>>> <b>Warning</b>: session_start() [<a
>>>> href='function.session-start'>function.session-start</a>]: Cannot send
>>>> session cookie - headers already sent in
>>>> <b>/home/twpalygj/public_html/Connections/gleanslo.php</b> on line
>>>> <b>2</b><br />
....cut...
>>> I would recommend you to rewrite the cron job to just connect to the
>>> database and do it's job,
>>
>> Do you mean putting the connection script directly into the cron
>> script rather than using an includes()?
>
> I mean it to use script which is just made for CLI which do not relay on
> session_start() as it's not used in CLI. Sure you can use includes, but
> see to only include configuration for the database, not scripts relaying
> on web requests.
I think the best idea would be to do proper separation of the various
components of the system. Have the session data in it's own world, the
database data in its own world, etc.

This way, he can continue having a single location for the database
connection, without having it do another 20 extra things.
>>> do have error handling in the script which
>>> gives you proper explanations why something goes wrong if something does
>>> that.
>>
>> The folder on the production server is outside of the 'public_html'
>> root folder so I cannot dorectly run it in my browser. I have to test
>> it inside another folder on my local server.
If you can, have your cron jobs run as scripts directly on the server,
not from pages on your website.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Mac OS X ML] how to install MongoDB driver
Next Topic: Trouble-shooting a script that doesn't retuen HTML
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 00:00:51 GMT 2024

Total time taken to generate the page: 0.04510 seconds