geonode
geonode copied to clipboard
Use flock for cron commands
https://github.com/GeoNode/geonode/blob/3d6ab6e0a5e536fecf75b28242d0301526f01e58/monitoring-cron#L1-L2
There is the remote possibility that these commands are executed more than once (it can happen that collect_metrics needs more than a minute on an overloaded server sometimes). I would suggest using flock -n lockfile command
to avoid that and skip the execution if the process is running. Something like this:
# */1 * * * * flock -n /tmp/collect_metrics.lock /usr/src/geonode/manage.sh collect_metrics -n -t xml >> /var/log/cron.log 2>&1
# 0 * * * * flock -n /tmp/dispatch_metrics.lock /usr/src/geonode/manage.sh dispatch_metrics >> /var/log/cron.log 2>&1