the cron is executed several times by several users

0

I have several CRONs in a raspberry pi and I've noticed that they run more than once, especially one that should run every 5 minutes but do it 3 times, I had the user write that I executed that file with a Random name so that the evidence is not deleted and is executed by PI, ROOT and www-data.

How can I prevent it from being executed so many times?

down I have the CRON

0 22 * * * rm /var/www/html/session/ses* >/dev/null 2>&1 # JOB_ID_6
*/10 * * * * /usr/bin/php /var/www/html/reparaMarcas.php >/dev/null 2>&1 # JOB_$
*/5 * * * * /opt/vc/bin/vcgencmd measure_temp > /var/www/html/temperatura.txt >$
*/30 * * * * /usr/bin/php /var/www/html/hotreboot.php >/dev/null 2>&1 # JOB_ID_$
0 22 * * * /usr/bin/php /var/www/html/ADM_AUTOMAIL.php >/dev/null 2>&1 # JOB_ID$
0 21 * * * sudo reboot >/dev/null 2>&1 # JOB_ID_13
0 5 * * * php /var/www/html/ADM_UPDATE.php >/dev/null 2>&1 # JOB_ID_15
*/5 * * * * php /var/www/html/checkStatus.php >/dev/null 2>&1 # JOB_ID_14
    
asked by Asdrubal Perez 11.09.2018 в 19:31
source

1 answer

0

Instead of running php directly in the cron, create a script and execute the line you want inside. But just before it checks that it is running, if it is, that it does not run and if it is.

Something like this:

EJECUCION='ps -ef |grep reparaMarcas.php|wc -l'  # 
if [ $($EJECUCION) = 1 ]; then  
 /usr/bin/php /var/www/html/reparaMarcas.php
fi

When doing a ps -ef, what works is coming out and more the grep itself that you do, so if there is more than 1 line, it is running.

    
answered by 12.09.2018 в 10:39