I ask for your help because I'm literally going crazy (given that I do not have much knowledge about it, but I'm trying to understand something).
This is my big problem :
I have a php job
. This job makes a check on DB but this is not important. The real problem is that this job must run every 30 min from 9 AM to 00PM. But:
- the job must be launched with this value:
-f 'YYYY-mm-dd H:i:s' -t 'YYYY-mm-dd H:i:s'
where-f
is the start date parameters and-t
the end date parameters. - when the jobs is run is necessary to have some check that controls if the job was already running and in this case must wait.
I thought that then I need a script that writes a file with something like "OK | last time of processing" or if something was wrong "KO | last time of succesfull elaboration".
So a crontab I must have a line like this: */30 9-23 * * * /path/script >/dev/null 2>&1
Then:
- the script must call the php function:
cd /data/httpd/magento && /opt/rh/php54/root/usr/bin/php /data/httpd/magento/job.php
- must launch the
job.php
with-f 'date -u "+%F %H:%M:%S"' -t 'date -u "+%F %H:%M:%S"'
with a range of 30 minutes.
Example: script start at 9 AM so the range date value is -f '2018-08-07 07:00:00' -t '2018-08-07 07:30:00'
and write in the log file something like "Elaboration OK | 2018-08-07 07:30:00")
- after 30 min the script run agains. Before running, it reads the log file and in particular the last processing in OK status and put the corret date range value for the run of php job.
I hope I was clear. Maybe it's bullshit but it's driving me crazy