croncentos6

Running `wsgetmail` service via Crontab job CentOS 6


I want to run the below via Crontab job and not working but when put them in sh file and run the sh manually it works fine.

Sh file path: /opt/etc/rt4/test.sh and the content as below:

wsgetmail --config=account01.json wsgetmail --config=account02.json

Running manually: sh /opt/etc/rt4/test.sh it works fine.

Crontab: */1 * * * * /opt/etc/rt4/test.sh

Crontab runs this file but those commands are not working.

I have other Crontab jobs and they are working fine as intended.


Solution

  • 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 shell script. in this case test.sh should looks like this:

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