Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3844802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:08:46+00:00 2026-05-19T16:08:46+00:00

I have created a cron job at my webserver. That cron runs a php

  • 0

I have created a cron job at my webserver. That cron runs a php file every few hours. It’s cache creating technique. But there’s a problem – my cron command looks like this: php -q /folder/phpfile.php . When i run “phpfile.php” directly from my browser, everything is ok, but when CRON runs that file, it ALWAYS outputs “headers already sent” error to “error_log”! Mentioned php file DO begins with if(!isset($_SESSION)) session_start(); but “error_log” show that exactly “session_start()” line is throwing the warning!

What’s wrong? Why is everything ok when i run that file with browser, but when cron does it, “headers already sent” is generated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:08:46+00:00Added an answer on May 19, 2026 at 4:08 pm

    Reason why it works in browser is probably because you have different php.ini settings for your web server and for cli-php.

    output_buffering directive is apperantly ON in your web-server and turned off in cli-php and it is right thing. Because no one wants to wait for content till script ends a job. We want to see what is happening when script is running.

    Wrong thing is that you send header with a cli script. Session is not really need in terminal, is it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a cron job for my website which runs every 2hours and
I have cron jobs setup that runs a few PHP scripts often. The issue
I have created a php file I want to run every day at 8am
We have a cron job that runs once a day and sends daily emails
I have created following command line to run cron job after every 2minutes 2
I have created a Job Queue module that processes jobs and constructs social-network type
I have a PHP script that runs this command: system(pdftohtml -i -noframes /home/myacc/pdfs/test.pdf); When
I have created a system that will be calculating data every month based on
I have a cron job on an Ubuntu Hardy VPS that only half works
I have a cron job scrape.sh that look like this: #!/bin/bash touch rage cd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.