0

There's a way to call a function every minute? i have an API call from my codeigniter controller with cURL, can php call that function every min?

Gil
  • 701
  • 1
  • 9
  • 20
  • 1
    I wouldn't do that within PHP, because you're keeping the parser running waiting around just to run your function every minute. Have you considered using cron for this task? – Dave Chen Oct 04 '16 at 20:57
  • Well i just need to recall an API every minute, how could i do that? _i had a headache using ajax (post) with codeigniter_ – Gil Oct 04 '16 at 21:01
  • I'm assuming you need to recall an API to update your database every minute, or so some action every minute within that function. Create a file called `every_minute.php`, move the function/code you need to run every minute, and edit your cron file to include `* * * * * php /path/to/file/every_minute.php`. Would this be a viable solution? – Dave Chen Oct 04 '16 at 21:05
  • 1
    Possible duplicate of [Using crontab to execute script every minute and another every 24 hours](http://stackoverflow.com/questions/5398014/using-crontab-to-execute-script-every-minute-and-another-every-24-hours) – Dekel Oct 04 '16 at 21:17

1 Answers1

0

in your hosting account you can create a CRONJOB and call it every 1 minute