D
D
Dmitry2014-03-20 19:01:37
PHP
Dmitry, 2014-03-20 19:01:37

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

8 answer(s)
D
Dmitry, 2014-03-21
@muldy

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;
}

R
Rsa97, 2014-03-20
@Rsa97

Does it make sense to restart the script for this? Use a loop

for ($year = 2013; $year >= 1900; $year--) {
    // здесь ваши действия
}

E
Evgeniy Samoilenko, 2014-03-20
@samoilenkoevgeniy

If you need it specifically for this, then just use the date() function built into php .

R
Ruslan, 2014-03-20
@iRusel

IMHO the best CRON solution.

D
Dmitry, 2014-03-20
@muldy

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!

V
Vampiro, 2014-03-20
@Vampiro

chord, we already sketched a variant about the cycle (((I will leave
set_time_limit (600);
as a bonus.

V
Vadim Yakovlev, 2014-03-21
@FrimInc

@muldy but why run a script when you can make a loop?
You can use
it but it will kill your server.

1
1001001 111, 2014-03-21
@IgorO2

Well, if you don't want to use cron then use Windows - task scheduler =)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question