The website is written in .php with the connection of MySQL
I had a file that's named PMautoemail.php It can be run successfully but I only want it to run once a day. Cronjob couldn't be set up as I am running in a windows server and this website will be run by other people too. What should I do?
Asked
Active
Viewed 172 times
1
Lim
- 39
- 8
-
[Setting Up A Cronjob In Windows Xampp](https://stackoverflow.com/questions/17442040/setting-up-a-cronjob-in-windows-xampp) – Anant Kumar Singh Feb 17 '20 at 08:14
-
@Lim, Check here https://stackoverflow.com/questions/33932617/how-can-i-run-a-php-script-automatically-daily-in-wamp-windows-environment – Rahul Kr Daman Feb 17 '20 at 08:31
2 Answers
2
You can use Windows Task Scheduler to run the file daily. Think of it as cronjob for Windows.
EDIT:
Another option: Windows Sub-system for Linux. https://docs.microsoft.com/en-us/windows/wsl/install-win10
Anant Kumar Singh
- 68,309
- 10
- 50
- 94
Vijay Joshi
- 881
- 8
- 17
-
Other than Windows Task Scheduler? Is there any other way than that, because it's not what I wanted. – Lim Feb 17 '20 at 08:25
-
There is one other option:Windows Subsystem for Linux. https://docs.microsoft.com/en-us/windows/wsl/install-win10. Using it you can run cronjobs like linux. – Vijay Joshi Feb 17 '20 at 08:27
-
I just found out that I will be using iPage to display the website, will the webside auto run the file in the domain? – Lim Feb 18 '20 at 07:23
0
Well, if you can't use CronJob, you can always start file in background and set some sleep. It's not proper solution, but sometimes be only option in some cases:
// init_linux.php
exec('php my_cron.php &');
// init_win.php
pclose(popen("start /B php my_cron.php", "r"));
// my_cron.php
// [... do some stuff ...];
sleep(60 * 60 * 24); // sleep for 1 day
Justinas
- 37,569
- 4
- 61
- 88