Php file to work alone automatically

Asked

Viewed 196 times

1

I have a php file that sends information to:

http://air.radiotime.com/Playing.ashx?partnerId=PARTNERID&partnerKey=PARTNERKEY&id=ID&title=MUSICA&artist=ARTISTA

However, it only sends information when I reload the page, is there any way to make it automatic without me having to be on the site? That is, working alone.

  • 1

    There are a million ways, one of them is to use while(1=1) and give a ignore_user_abort(true). Another is using cronjob... To define which is the best will depend on the objective of this (and if you have reason to do so), anyway, without details can not inform.

  • If the machine is linux, a simple suggestion is the creation and a cron job that would call this PHP script every period you specify.

  • I find it feasible to use a cron job

  • 1

    I used cron job, it worked.

1 answer

0


You can run this PHP script by command line. Just run the following command on the terminal:

php caminho/para/o/arquivo.php

There you have 2 options, in this script create an infinite loop and let the file always running.

while (1==1) {
    // Codigo que faz a request
}

Or set up in cron (or another task scheduler) to run this script in a given time interval.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.