Answer the question
In order to leave comments, you need to log in
How to run PHP script daily?
I have the following task:
We have written a script that creates new posts for WordPress by pulling data from a database that comes in via FTP from outside. The script is launched by entering the address of a hidden page into the browser line (for example, "_www.nashwebsite.com/stranica-id=1000").
Now we are scratching our heads how to make this script run itself daily (without anyone's intervention).
I thought that there must already be some kind of service (perhaps even a paid one) that can visit the page at the specified time once a day. But alas, I can't find one.
Answer the question
In order to leave comments, you need to log in
Add its execution to cron . If adding just via the command line interpreter ( php имя_скрипта
), be aware that the environment variables may not be the same as usual. Perhaps it would be easier to add a curl call to cron with the quiet option and the address of the desired page.
curl www.nashwebsite.com/stranica-id=1000 -O /some/file.log 2>/dev/null
Plug into cron.
If you don't care where to call the script from (from the local machine or external environment), then set up the task scheduler on an always-on machine with an Internet connection.
Although in such cases a scheduler on a web server (cron - *NIX, a scheduler on windows) is the most correct solution.
+1 to all.
And if it’s just hosting, and not servers at all, cron is usually placed in the control panel as a separate bag-page. In direct admin it is called "Task Scheduler".
Once a day, you need to put "* /
24" in the column "hour"
Since we just had to follow the link to run the script, Cron is not very suitable for us, but still very grateful to everyone!
There is a Chrome plugin that does this. There is also a Windows Task Scheduler which can also do this.
In general, I have not yet found another solution so that I can do without intervention.
They already wrote about crons here.
And WP can also run internal scheduled tasks itself - once an hour, once or twice a day.
There is such a service: Cron-Job.ru , moreover, Russian-language and free.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question