cronrt

fetching email from outlook O365 by App-wsgetmail for RT using crontab not working


I have configured the modern authentication for O365 using App::wsgetmail module for RT, everything works fine when I run the the wsgetmail --config=config1.json via terminal it can access the email's inbox and create the ticket in RT and mark the email as read but when I am trying to use the crontab to do the same work periodically getting no result. the corntab works with other cornjobs that I have for other tasks and only it is not working with wsgetmail. the crontab looks like this:

*/1 * * * * wsgetmail --config=/path_to_config_directory/config1.json

Note:

Any idea about this issue that I am facing with?


Solution

  • I have finally resolved the issue and posting the answer here for others that may face with same issue. The crontab and terminal are two different environments, the wsgetmail perl module command is recognizable for terminal but to make it recognizable for corntab we have to add the full path to the module (wsgetmail) in the crontab.

    */1 * * * * /usr/local/bin/wsgetmail --config=/path_to_config_directory/config1.json
    

    or we can create a shell script and call the script in crontab. in this case test.sh will looks like this:

    #!/bin/bash
    /usr/local/bin/wsgetmail --config=account01.json 
    /usr/local/bin/wsgetmail --config=account02.json