Hi all,

I do some script to run status.cron.php every 3 secounds just following this steps :

Tested on (CentOS 8) ( PHP Server Monitor v3.5.0.) (PHP 7.2.24) (5.5.5-10.3.17-MariaDB) (Apache/2.4.37).

Create new file shell script to run it by cron job command for PHP Server Monitor to refresh status every 3 second

cd /root
nano every5second.sh

Add this :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#!/bin/bash

# Run cron jop for update status SERVER MONITOR

PID=$$

# The self killer
(sleep 57;kill $PID)&

while true
        do
           /usr/bin/php /var/www/html/mon/cron/status.cron.php

           sleep 3
        done

Save and exit

chmod +x /root/every5second.sh

Note :
(sleep 57;kill $PID)&
// sleep 57 : keep runing shell script 57 s
// Why 57 s : Every 60 s cron run shell scrips - Every 3 s run php file in the loop (60 - 3 = 57)
// $PID : kill self PID before next shell script running from crontab to avoid (Cron is already running) and protect memory.

Run shell script from cron every 1 minut :

nano /etc/crontab

Add this :

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root


*/1 * * * * root /root/every5second.sh

Save and exit

///1 * * * root /root/every5second.sh : run this shell script every 1 min (60 s).

Don't forget

Each service added : Timeout should be 3 s to get effective result

Enjoy !

 

Last edit: Mustafa AlShingiti 2020-06-22