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

  • Home
  • SEARCH
  • 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 577251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:08:01+00:00 2026-05-13T14:08:01+00:00

I know there are many posts about using CRON to run a php file.

  • 0

I know there are many posts about using CRON to run a php file. But, in the world of shared hosting, and ease of setup for a user, I don’t want to have to mess with that.

I found another solution online that has to do with sockets. Just wanted to get everyones take on this, and tell me if this is a good or bad idea. Sounds like it works well.

Thoughts?

//Open socket connection to cron.php
$socketcon = fsockopen($_SERVER['HTTP_HOST'],80,$errorno,$errorstr,10);
if($socketcon) {
$socketdata = "GET /cron.php HTTP 1.1\r\nHost: ".$_SERVER['HTTP_HOST']."\r\nConnection: Close\r\n\r\n";
fwrite($socketcon,$socketdata);
//Normally you would get all the data back with fgets and wait until $socketcon reaches feof.
//In this case, we just do this:
fclose($socketcon);
} else {
//something went wrong. Put your error handler here.
}

cron.php:

//This script does all the work.
sleep(200);
//To prove that this works we will create an empty file here, after the sleep is done.
//Make sure that the webserver can write in the directory you're testing this file in.
$handle = fopen('test.txt','w');
fclose($handle);

Found the script from a blog post: http://syn.ac/tech/13/creating-php-cronjobs-without-cron-and-php-cli/

  • 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-13T14:08:01+00:00Added an answer on May 13, 2026 at 2:08 pm

    It’s not a bad method, but you need to ensure that by closing the socket it isn’t just terminating the script before it finishes. You can set sockets to non-blocking.

    I would still use a cron job, even if it is a bit of a pain.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can't comment definitively other than to say that I… May 16, 2026 at 12:09 pm
  • Editorial Team
    Editorial Team added an answer I've finally found a solution to this problem, and it's… May 16, 2026 at 12:09 pm
  • Editorial Team
    Editorial Team added an answer You can't do it, the underlying type for enums will… May 16, 2026 at 12:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

There are many legends about them. I want to know the truth. What are
I have read some posts about this topic and the answers are comet, reverse
Is there someplace that details how to setup your POCO's when using the SimpleRepository
I been wondering about this for a while. It seems like there are so
I have entities Post and Tag , where there is a many-to-many relationship between
I know this is somewhat of a dead horse, but I'm not finding a
Hi guys I know that this is really bad idea but I want join
I have a friend who's using FluxBB and he has just installed a modification
I've run into this problem with testing. Let's assume I have two models, User
I hate Wordpress for numerous reasons, but clients love it because it gives them

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.