1

I am very wonder how to run php script always or specific time WITHOUT connection or call of user/admin. For example, I am making a push-messaging alarm application. This app sends message to user when time is 5:00 PM. But push-message system requires php server page that requests FCM(push-message server) request.(This app is just example, so please don't answer me how to make push message.)

This is not the only situation I have to solve. If I have many advertisers who want to advertise on my website, and some of advertisers pay for limited-time advertise, I have to stop providing that AD after 5:00 PM.

What I want to ask is: How to run php code in background? (likely purpose to make time-alart push message) and run code in PARTICULAR TIME or ALL TIME?

Stn Dev
  • 11
  • 2
  • 1
    You can use cronjobs to run your script at a specific time to check if an alert needs to be sent to the user of to remove a certain ad from the list as it has expired – Igor Ilic May 23 '18 at 06:43
  • You can use Cronjobs Script and set the URL on server at purticular time and it will be call automatically at set time and date or u can set it for each day to. – Balsara Dhaval May 23 '18 at 06:50
  • 1
    Possible duplicate of [How to create cron job using PHP?](https://stackoverflow.com/questions/18737407/how-to-create-cron-job-using-php) – 5eeker May 23 '18 at 06:55
  • In windows server Task Scheduler can be used – ManiMuthuPandi May 23 '18 at 06:57

2 Answers2

0

You can Use cronjob to run your file in specific time

0

What you need is a CRON job to run in background. CRON are scheduled jobs which are set to be executed at a particular time depending on your need.

Basically it will be just a file stored on your server, which will be executed by the cron daemon. (a background process)

Refer below link for an example :

https://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428

5eeker
  • 1,016
  • 1
  • 9
  • 30