A
A
Alex2015-07-02 10:53:25
linux
Alex, 2015-07-02 10:53:25

How to run a script/url via crontab that takes a long time (20-25 minutes)?

I create an entry in crontab

* */6 * * * /usr/bin/wget -q -O- http://my-site/my_url

While mail was simply sent to the specified url, everything was ok. But when I connected the "Combat script" that generates a report on average 20 minutes, the following happens:
- Cron runs as it should, but for an hour from the moment it was started, it repeats every minute without waiting for the end of the process.
Actually the question is how do I make cron wait for the process to complete.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
V
Vladimir, 2015-07-02
@mr_ko

0 */6 * * * /usr/bin/wget -q -O- http://my-site/my_url

if according to your rule, then every minute of every sixth hour

S
ShamblerR, 2015-07-02
@ShamblerR

LOCK_FILE=/tmp/wget.lock
* */6 * * * /usr/bin/wget -q -O- http://my-site/my_url

M
Melkij, 2015-07-02
@melkij

First, run it through the CLI. Through http, too many people can kill it by timeout, from wget to web servers.
Secondly, add a check with a limit on the number of running processes to the script code. Classically, this is implemented through a pid file.

V
Vladimir B., 2015-07-02
@ange007

Maybe as an option just make the cron run for a longer time (although you have a hardened script apparently) ?
Well, and so - keep in the database or file a variable responsible for the state of the script, and do not start it on a new one if it is available.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question