1

I have a question.. Is there any way to run a php function once a day. For example. I have a function which find every Sunday of next year and apply some offers (such as discount to all products etc.) This function run every time that users refresh the page. I want to run this function once a day in order to check if that day is Sunday. If Sunday then it will execute, otherwise It will not execute. Any ideas?

was
  • 103
  • 2
  • 3
  • 12

3 Answers3

0

This can be done using cron. If you want another way without using cron check this stack overflow question.

Community
  • 1
  • 1
Johny
  • 2,128
  • 3
  • 20
  • 33
0

If you're using Windows you can use the task scheduler.

Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
0

If you're using LINUX

Use Cron Jobs

# run the script at 4:30am every day
30 4 * * * /usr/local/bin/php /home/me/myscript.php

If you're using WINDOWS

Use sheduled task

If you're using XAMP

C:\xampp\php\php.exe -f c:/xampp/htdocs/myscript.php
meda
  • 45,103
  • 14
  • 92
  • 122