Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10732
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: cron job and headers sent error |
| Date | 2013-09-08 22:30 +0200 |
| Message-ID | <b94532Fl40jU1@mid.individual.net> (permalink) |
| References | <tduo29dbnp2l23rjvvol64iveibjup6189@4ax.com> <b93giuFgnkfU1@mid.individual.net> <9j5p29tvpi13ssb2r3bq1brgvf7hosvr45@4ax.com> |
On 08/09/13 17:35, Richard Yates wrote: > On Sun, 08 Sep 2013 16:40:30 +0200, "J.O. Aho" <user@example.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 /> >> >> This is a warning you usually get when you have white spaces or bom >> sequence in your files. Check all your files that are used, that they do >> not have anything before or after the PHP tages (<?php and ?>). > > Thanks. I will check again for spaces. What is 'bom sequence'? I think Peter made a really good explanation, so I won't repeat it here. >> As you are anyway running a cron job, why do you call it over tcp/ip? > > I don't know what you mean by calling it over tcp/ip. It is set up via > cPanel and runs automatically on the domain host server. Your error message contains HTML and uses session_start(), which are something you will not use if you run the script properly as a cron job, those I guess you made a HTTP/HTTPS request to the script in question. >> 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. >> 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. Rule number one, set up a test environment which is similar to your production environment, those you will see that the scripts will work when you move it from your test environment to production environment. Today there is VirtualBox which can work really well to test things, just remember to only have those packages installed in the test environment as you have in live. >> A good thing is also log to syslog so you can see the job has been >> properly done and you can also forward that to splunk or similar. > > The domain host has the cron job in a folder that I can upload to. The > error_log there has the same warning message that was sent. I do not > see any syslog. I do not know what splunk is. syslog is on the systems /var/log directory, you don't seem to have access there, but your web hosting company has setup system so that you get access to logs belonging to your site in your home directory instead. For logging use syslog() see more about it at www.php.net/syslog Splunk is a platform for collecting, searching, monitoring and analyzing machine data. Many times used to centralize your logs and make it easier to search for information. Most likely you don't need it as you only have a hosted service. -- //Aho
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
cron job and headers sent error Richard Yates <richard@yatesguitar.com> - 2013-09-08 06:36 -0700
Re: cron job and headers sent error "J.O. Aho" <user@example.net> - 2013-09-08 16:40 +0200
Re: cron job and headers sent error Richard Yates <richard@yatesguitar.com> - 2013-09-08 08:35 -0700
Re: cron job and headers sent error "Peter H. Coffin" <hellsop@ninehells.com> - 2013-09-08 14:34 -0500
Re: cron job and headers sent error "J.O. Aho" <user@example.net> - 2013-09-08 22:30 +0200
Re: cron job and headers sent error Richard Yates <richard@yatesguitar.com> - 2013-09-08 13:42 -0700
Re: cron job and headers sent error T0xicCode <t0xic@co.de> - 2013-09-08 22:21 -0400
Re: cron job and headers sent error Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-08 21:09 +0000
Re: cron job and headers sent error Richard Yates <richard@yatesguitar.com> - 2013-09-09 04:29 -0700
csiph-web