Answer the question
In order to leave comments, you need to log in
How to execute php script multiple times?
Hello!
So I still do not quite understand all the intricacies of working with PHP, so I ask this question!
I wrote a script that works with a date, namely a year!
Accordingly, after its execution, it is required that it be performed again and set a different date, for example, the first time is 2013, the next - 1 year.
Hence - how can this task be performed at all, besides using CRON?
Answer the question
In order to leave comments, you need to log in
Prompted and made with the help of Perl, and set the task in Cron!
Here is the code, maybe it will be useful for someone:
my $start_year=2013;
my $stop_year=1949;
my $interval=100;
foreach (reverse($stop_year..$start_year)){
`wget -q -O /dev/null "http://site.ru/get_programm.php\?year=$_\&auto=1"`;
sleep $interval;
}
Does it make sense to restart the script for this? Use a loop
for ($year = 2013; $year >= 1900; $year--) {
// здесь ваши действия
}
If you need it specifically for this, then just use the date() function built into php .
Date() will only give me the current date, and I need to use the script multiple times, but with a different date minus one year!
chord, we already sketched a variant about the cycle (((I will leave
set_time_limit (600);
as a bonus.
@muldy but why run a script when you can make a loop?
You can use
it but it will kill your server.
Well, if you don't want to use cron then use Windows - task scheduler =)))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question