duan89197 2018-08-07 14:06
浏览 53

如何使用不同的值每30分钟运行一次php作业?

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:

  1. 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.
  2. 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:

  1. the script must call the php function: cd /data/httpd/magento && /opt/rh/php54/root/usr/bin/php /data/httpd/magento/job.php
  2. 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")

  1. 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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 oracle集群安装出bug
    • ¥15 关于#python#的问题:自动化测试
    • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
    • ¥15 教务系统账号被盗号如何追溯设备
    • ¥20 delta降尺度方法,未来数据怎么降尺度
    • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效