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 8055303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:20:37+00:00 2026-06-05T08:20:37+00:00

//i need to run this script repetadly and the time interval can be set

  • 0

//i need to run this script repetadly and the time interval can be set by a user

// checking the internet connection

if (!$sock = fsockopen("www.google.com", 80, $errno, $errstr,20))
    {
?>
<script type="text/javascript">

alert("Connection problem");

</script>

<?php       
    }

// retriving data from database and checking the site is down

else
    {
    for($i=0;$i<count($res);$i++)
        {
        $fp=fsockopen($res[$i]['url'],80,$errno,$errstr,30);
        if($fp==false)
            {
 ?>
 <script type="text/javascript">

 alert("Website is down");

 </script>

 <?php

// writing data to database and sending mail

mail($email[0]['email_id'],"website is down",$res[$i]['url']." is down");
    $inputs=array('website_id'=>$res[$i['website_id'],
    'date'=>date("Y-m-d H:i:s"),'reason'=>"website down");
$obj3->addLog($inputs);
         }
    }
}
sleep(300);
}
  • 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-06-05T08:20:40+00:00Added an answer on June 5, 2026 at 8:20 am

    Your problem with cron is this "and the time interval can be set by a user".

    You can use cron such way, that you run script every 30 seconds or every N seconds. That is your smallest granularity for running script.

    Now, if user sets that script must be run every 30 minutes, first thing you do at script is check that, if script needs to proceed – if last run was before that 30 minutes that user set. Script pseudo goes like this:

    1) load last run from DB, compare it with interval - do we need to proceed, if not exit
    2) do what script needs to do
    3) save to the DB last run time
    

    Of course this all is only necessary, if user needs to be able to dynamically change run interval and dont want to touch cron.

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

Sidebar

Related Questions

I need to run this php script http://db2express/imacs/radek/3.1/rationalTest.php?mode=create The processing time is about 10mins
i have shell script written in RedHat OS. I need to run this script
I need every night to run a task by Schedular (CRON). This task can
I have to run this script: /scripts/saveData.rb And in it, I need to use
I need to run this line from my c++ program: java -jar test.jar text1
First off, I need to give a disclaimer: DO NOT RUN THIS JAVASCRIPT It
I need to run a loop in SQL. Google this is a little hard
I have a statement similar to this that I need to run in Linq.
For reasons that are irrelevant to this question I'll need to run several SQLite
I have an app hosted on Heroku and this app need to run some

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.