A newly created crontab job is failing because the program can't read a .json file containing credentials in the same directory. Both files are contained in a
/home/deploy/app/ folder. Crontab executes
/home/deploy/app/app which needs to read
home/deploy/app/config.json to execute. The program runs fine a the
deploy user, but fails when run by crontab.
I am sure this is the reason the program is failing since I directed the crontab job to log its output, and I can see that the program is unable to read the
config.json file. The
app has the following permissions
-rwxr-xr-x 1 deploy deploy and the
-rw-rw-r-- 1 deploy deploy.
The crontab entry is:
10 0,6,9,12,15,18 * * * /home/deploy/gocode/bin/BuoyBot > /home/deploy/buoybot.log 2>&1
The cron log records the error from the app, which indicates is it unable to load the
config.json file stored in the same folder as the app.
error loading config.json: invalid argument
This error does not occur when the program is run manually from within the
UPDATE: The solution, as suggested below, was to reference the full path of the
config.json file within the app (
/home/user/app/config.json), rather than a reference to the local directory (