0

I have a javascript file that listens polls an api constantly waiting for updates. This file is linked to my index.html file. How can I bring this live and have it running 24/7 without needing to have it open in my browser?

Username
  • 1,950
  • 2
  • 12
  • 21
  • You might be helped with this question about PhP Cron (need you to turn your project into server-side project using PhP) : http://stackoverflow.com/questions/4558601/how-can-i-make-my-php-script-run-at-a-certain-time-everyday – Anwar Aug 31 '15 at 16:50
  • In-browser JavaScript *really* isn't the tool for this. Writing some kind of background application which runs on the computer either constantly (daemon process in Linux, Windows Service in Windows, etc.) or periodically (schedule task, usually with Cron or some other host-native task scheduler) would be the way to go. With the advent of things like node.js you may still be able to do this in JavaScript. But it may be easier to use something else. – David Aug 31 '15 at 16:53

1 Answers1

0

You can use Cronjobs. If your website is hosted and you have Linux, you can set a cronjob to run this script every minute. But you will have to use php. How to create cron job using PHP?

Community
  • 1
  • 1
morha13
  • 1,847
  • 3
  • 21
  • 42