如何使用代码触发cron作业?

时间:2015-09-18 14:44:47

标签: php cron codeception

让我首先说我是代码新手,我尝试在线搜索解决方案,但我没有得到任何结果。

有没有办法通过代码或php触发cron作业?

1 个答案:

答案 0 :(得分:0)

首先安装新的crontab

请参阅:How To Use Cron To Automate Tasks On a VPS

第二在crontab中执行以下命令:

cd / YOUR_CODECEPTION_PROJECT_PATH && php vendor / bin / codecept运行

例如:

$ crontab -e

service cloud.firestore {
  match /databases/{database}/documents {

    function isSignedIn() {
      return request.auth != null;
    }
    function getRole(rsc) {
      // Read from the 'roles' map in the resource (rsc)
      return rsc.data.roles[request.auth.uid];
    }
    function isOneOfRoles(rsc, array) {
      // Determine if the user is one of an array of roles
      return isSignedIn() && (getRole(rsc) in array);
    }

    // ORGANIZATIONS
    match /organizations/{organization} {

      allow write: if isOneOfRoles(resource, ['owner']);
      allow read: if isOneOfRoles(resource, ['owner', 'member']);

    }

    // Any subcollections under ORGANIZATION
    match /organizations/{organization}/{sub=**} {

      allow write: if isOneOfRoles(get(/databases/$(database)/documents/organizations/$(organization)), ['owner']);
      allow read: if isOneOfRoles(get(/databases/$(database)/documents/organizations/$(organization)), ['owner', 'member']);

    }
  }
}

它在带有代码接收2.5的ubuntu 16.04中工作。