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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:55:30+00:00 2026-05-24T17:55:30+00:00

i want to execute a php script every day. i have a bash script

  • 0

i want to execute a php script every day. i have a bash script containing below lines. and i was doing it with that script. but by this way, it can be executed from another computer. lets say webservername=”slmnbr” any body can call myscript with

xhttp://slmnbr/myscript.php.

i want to call it from just server.

BASE_URL=http://`get-webservername`
/usr/bin/wget --no-check-certificate --timeout=0 -O - "$BASE_URL/myscript.php"

thanks in advance

  • 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-24T17:55:31+00:00Added an answer on May 24, 2026 at 5:55 pm

    You need to have PHP CLI (command line interface) to do this. It often comes with the PHP installation package (or a separate package).

    So as @James mentioned it you need to precede you script name with the CLI PHP executable which in windows is php.exe somewhere in your install directory.

    In UN*X systems it’s somewhere in /usr/bin or /usr/local/bin or /opt/local/bin. If it is in the PATH you can simply execute it like this:

    php your_script.php
    

    But keep in mind that running your script from server will be not the same as running from a webserver. For e.g. you won’t have the POST or GET variables. So your script may not work.

    Update

    You can make the cron ran scripts unreachable for your webserver by making it unreadable by the user who is running the PHP scripts by the http daemon (usually www-data).

    I recommend to make it readable only by the user who is running it from cron:

    chown cronuser your_script.php
    chmod 0400 your_script.php
    

    Update2

    If you’re running your script in cron with the same user as the webserver does, then at the top of your script stop it from being executed:

    if (!(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR']))) {
      header('HTTP/1.1 403 Forbidden');
      exit;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute a php-script from php that will use different constants and
I want to execute a script every 30mins, but i want to use it
I want to execute this script (view source) that uses Google Translate AJAX API
I have verified that my php script runs from the command line, but it
Let's say I want to execute a PHP script. Which way is better? This:
I have a cron script that executes a PHP script every 10 minutes. The
im want to execute a php script every 10 min in order to retrive
I have a PHP script that needs to execute programmes that will work on
I have written a PHP script which generates an SQL file containing all tables
I want to execute multiple shell-commands with php's exec command. The commands have to

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.