1
1
101-s2021-03-12 12:33:34
linux
101-s, 2021-03-12 12:33:34

How to run one script in linux with double run protection?

in the crown set up launch via flock

*/1 * * * * flock -n /tmp/lock -c /var/www/python/x/run.sh > /var/www/python/x/logs/log.txt 2>&1


but it throws error
flock: -c requires exactly one command argument

like this also tried
*/1 * * * * flock -n /tmp/lock -c '/var/www/python/venv_x/bin/python3 /var/www/python/x/test.py' > /var/www/python/x/logs/log.txt 2>&1


Tell me how to fix or other options for running a python script in CentOs

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dmitriev, 2021-03-12
@101-s

Add to the beginning of the script to check a specific lck file and exit if it exists.
If not, create a file, run the script and delete the file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question