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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:51:40+00:00 2026-06-04T16:51:40+00:00

I have a PHP script, which does something in a matter of seconds (not

  • 0

I have a PHP script, which does something in a matter of seconds (not running for a long time). I need this script to be executed, let’s assume, 12 (this can change) times a day. 24 / 12 = 2 hours.

I could just execute the script each 2 hours, but I need it to be randomized along the 24 hours.

That means that script doesn’t have to be executed at 01:05 PM, 03:05 PM, 05:05 PM, but rather at 01:37 PM, 03:11 PM, 05:46 PM. I guess you’ve understand the point. Sorry for not being very clear.

(cron & other tools (if required) can be installed. running debian 6)

Bounty (100 rep) will be offered for a working solution.

  • 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-04T16:51:41+00:00Added an answer on June 4, 2026 at 4:51 pm

    Let’s say you want your script to run N times a day. Then create a bash script my_php_runner.bash like the following:

    #!/bin/bash
    
    N=12  # 50 times a day
    
    let WAIT_TIME=86400/$N
    
    while [[ $n -gt 0 ]]; do
        php yourscript.php
    
        # Sleep for $WAIT +/- 300 seconds
        sleep $(( $WAIT - 300 + $RANDOM%600 ))
        ((n--))
    done
    

    It will run your script 12 times, waiting between 115 and 125 minutes between runs. Then add something like

    0 0 * * * my_php_runner.bash
    

    in cron to run the bash script once a day.

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

Sidebar

Related Questions

I have this PHP script which i'm grabbing images from a directory and displaying
I have an AJAX request (using JQuery) that calls a PHP script which does
I have PHP script, which is requested by user. In this script I want
I have a PHP script which downloads files to the client, in a new
I have a PHP script which checks on a _SESSION variable (upon creating a
I have a php script which saves the original image, then resizes it -
I have a PHP script which creates and listens on a port for connections
I have a PHP script which is generating buttons to each content schedule. The
I have a PHP search script which I've altered slightly and works well for
Here I have a simple php script which displays some values from a database

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.