How do I run a PHP file every 5 minutes or so? I've attempted to use cron, but it doesn't seem to be working. Say I wanted my site to run a php file that plays a sound. How do I make it so that the php file is ran every 5 minutes, so that the sound is played every 5 minutes. I know JavaScript can make it so the function can be run at a set interval, but I want the file to do the same.
Reason for this is that I'm creating a site and I want the users to be notified live. In order to do this, I need the php file to run so it can detect changes for users notifications and then make the noise if the user gets a new notification. If more info is needed, I can provide.
Edit:
So here is what I used to try and run a cron localhost Run Cron Job on PHP Script, on localhost in Windows
My script.bat file
"C:\Xammp\php\php.exe" -f "C:\Xammp\htdocs\SocialMedia\Admin\Users\Notification.php"
And my shellscript.vbs file
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Xammp\htdocs\SocialMedia\Site\script.bat" & Chr(34), 0
Set WinScriptHost = Nothing
I've followed what they said in that post, but I don't see any change in my console log for networks. It should show a file being ran every x minutes but it doesn't
Edit: Although my question isn't completely answered, this site is where I found my answer. https://web-push-book.gauntface.com/chapter-01/02-how-push-works/ Thanks!
Edit - This was the answer to my question - https://developer.hyvor.com/php/ajax-long-polling