E
E
Evgeny Zhukov2018-01-18 13:46:14
PHP
Evgeny Zhukov, 2018-01-18 13:46:14

How to make a bypass on requests on time?

Good day. There is a module to which you need to make a request through the address bar, each time you need to change a couple of numbers, the page number for example.
site.ru/mod.php?main=0&url= https://site.ru/page/123&page=1
How do I plan so that I create a list of 1000 request links so that cron bypasses them one by one, the image to a new link after 30 sec.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nox1725, 2018-01-20
@nox1725

First, create a script in this style, name if, for example:

#!/usr/bin/env bash

# обход прочитанных строк из файла
while read link; do
    # Строка - это ссылка, ходим к ней через wget
    # -q говорит о минимизации вывода
    # -O /dev/null "сохранит результат вникуда"
    wget -q "${link}" -O /dev/null
    
    # Пауза 30 секунд
    sleep 30
# Это конструкция читает из файла (тут должен быть путь до него)
done < <(cat /path/to/links.txt)

Then just add it to the cron with the desired frequency
PS Please note that 1000 links with a pause of 30 seconds is more than 8 hours of work, so you will not be able to run such a script often (or you will need to reduce the pause)
PPS If the numbers of "pages" or other arguments go in order, for example, you can make a simpler script - without a file with links

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question