r-soy Posted December 30, 2014 Share Posted December 30, 2014 Hello ! How I can make a script of my PHP code to work even if my website is not running Can I make this with php ? Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/ Share on other sites More sharing options...
ginerjm Posted December 30, 2014 Share Posted December 30, 2014 If your website is not running, where is this php code supposed to be executed? Just on your pc? If that is the question you have to install php on your client and start it and then execute the script. Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501167 Share on other sites More sharing options...
NotionCommotion Posted December 30, 2014 Share Posted December 30, 2014 You could also run PHP from the command line instead of from a web server (but as ginerjm stated, you need to have PHP installed) Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501168 Share on other sites More sharing options...
r-soy Posted December 30, 2014 Author Share Posted December 30, 2014 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 https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501179 Share on other sites More sharing options...
ginerjm Posted December 30, 2014 Share Posted December 30, 2014 See my previous answer Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501180 Share on other sites More sharing options...
r-soy Posted December 30, 2014 Author Share Posted December 30, 2014 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 https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501186 Share on other sites More sharing options...
NotionCommotion Posted December 30, 2014 Share Posted December 30, 2014 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? Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501188 Share on other sites More sharing options...
ginerjm Posted December 30, 2014 Share Posted December 30, 2014 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 https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501190 Share on other sites More sharing options...
r-soy Posted December 30, 2014 Author Share Posted December 30, 2014 thanks for helping . I have found cron job which do my job . Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501194 Share on other sites More sharing options...
r-soy Posted December 31, 2014 Author Share Posted December 31, 2014 Thanks ginerjm Link to comment https://forums.phpfreaks.com/topic/293523-how-i-can-make-a-script-of-my-php-code-to-work-even-if-my-website-is-not-running/#findComment-1501321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.