F
F
Fyodor2014-04-21 14:43:06
PHP
Fyodor, 2014-04-21 14:43:06

How in Centos, when composing a Cron task, to prevent the script from being called before the previous call completes?

Now it is called like this (configured in VESTA)

php /home/admin/web/default.domain/public_html/xxx/hotels.php

It is necessary that a new call does not occur before the old one completes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Zhivotnev, 2014-04-21
@Richard_Ferlow

flock -n /tmp/blah.lock -c 'php /home/admin/web/default.domain/public_html/xxx/hotels.php'

This command needs to be run. If flock is not installed then yum install flock to start with.

A
Alexey Lesovsky, 2014-04-21
@lesovsky

if [ ! -f /tmp/lock ]; then touch /tmp/lock; php hotels.php; rm /tmp/lock; else exit 0; fi

either way
We check the lock-file, if it does not exist, then create it, execute the script, delete it. if the lock file exists, then we just exit.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question