Jump to content

How I can make a script of my PHP code to work even if my website is not running?


r-soy
Go to solution Solved by NotionCommotion,

Recommended Posts

I want to execute php code  each 24 hours like scheduling tasks and cornTab on Linux and Unix.

 

Or for example to update the content of website, to remove expired articles, to send email on a given date and... etc.

 

I hope you got it 

 

thanks 

Link to comment
Share on other sites

How I can explain that !!!

 

For example :  You have  4 members you want everyday send to them a text such ( hello ! ) without enter your website some job ruining all the time . 

 

 

Another example :  You have Button in your page, and if you click that Button will send a text to users, but I don't want to click that Button I want each 24 hours that text sending to users no need to click the Button  

 

in another words ( I have quiz page and every day I send the questions of that day by clicking a button but actually I want this task to be done automatically by the page itself ) 

Link to comment
Share on other sites

  • Solution

r-soy,

 

The PHP script has to be located on a server which is running PHP.

 

For timing, you could use a cron job as you indicated.

 

To initiate the PHP script on the same server as the cron program, use something like /usr/local/bin/php -q /path/to/your/file/under/the/html/root/script.php.

 

If it is on a different server, you can use curl(), but you need some password authentication because it is publicly assessable.

 

When the PHP script is executed, it could check a database to see if anything is slated to go out, or do whatever you want it to do.

 

Which part do you need more information?

Edited by NotionCommotion
Link to comment
Share on other sites

The question was 'are you wanting to run this on your server or on your client?". Perfectly legitimate when you said "when your website is not running", whatever that means.

 

A cron job is certainly a simple and easy way to do what you want. But you didn't answer my question, so I didn't know if a Cron job was even possible since I chose to assume you meant your server was down.

 

What does "website is not running" even mean?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.