Custom jobs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlessioMa
    Member
    • May 2024
    • 38

    #1

    Custom jobs

    hello everyone,
    I have created a cron jobs in a custom extension

    custom\Espo\Modules\NameEstension\Jobs\JobCustom.p hp

    custom\Espo\Modules\NameEstension\Resources\Jobs\J obs.json.

    {
    "nomeJob": {
    "name": "desrrizione",
    "jobClassName": "Espo\\Modules\\NomeModulo\\Jobs\\CustomJob"
    }
    }



    If I execute it manually it works, while if I set it from the administration panel it does not.

    Click image for larger version

Name:	Immagine 2025-06-19 123640.png
Views:	43
Size:	24.5 KB
ID:	118785
  • item
    Active Community Member
    • Mar 2017
    • 1532

    #2
    Hi,
    i have just do that but not in module folder :

    custom/Espo/Custom/Resources/metadata/app/scheduledJobs.json

    PHP Code:
    {
        
    "MyJob":{
            
    "jobClassName""Espo\\Custom\\Jobs\\MyJob"
        
    }

    and
    custom/Espo/Custom/Jobs/MyJob.php

    PHP Code:

    <?php
    namespace Espo\Custom\Jobs;

    use 
    Espo\Core\Job\Job;
    use 
    Espo\Core\Job\Job\Data;
    use 
    Espo\ORM\Entity;
    use 
    Espo\Core\ORM\EntityManager;
    use 
    Espo\Core\Utils\Log;

    class 
    MyJob implements Job
    {
        public function 
    __construct(
            private 
    EntityManager $em,
            private 
    Log $log,
        ){}

        public function 
    run(Data $data) : void
        
    {}
    }
    And run job.

    You have a mistake maybe :

    custom\Espo\Modules\NameEstension\Jobs\JobCustom.p hp
    Espo\\Modules\\NomeModulo\\Jobs\\CustomJob

    JobCustom or CustomJob ?

    don't forget clear_cache and rebuild
    Last edited by item; 06-19-2025, 06:10 PM.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • AlessioMa
      Member
      • May 2024
      • 38

      #3
      everything ok, it works. I had not inserted the snippet in the server to enable the espo cron.
      Thanks for the reply

      Comment

      Working...