We are running a Cron job that executes the script in our remote DB server hosted in google cloud and Debian Linux 10 OS. The script will log in to the remote server and executes some Database queries. It works fine when we run the script manually, we are getting the proper output. When we run the same script on Cronjob we are not getting the proper output. We are getting below output when we run the script from cron but if we execute manually it is fetching the records.
Query OK, 0 rows affected Records: 0 Deleted: 0 Skipped: 0 Warnings: 0
when we tried to debug the issue we found the script is not fetching the root environment variable and we added the cron in /etc/crontab instead of crontab -e. After adding we got the permission issue and we fixed it by providing execute permission.
Once we provided the permission we are not getting any error but the log is not printing, we are unable to find the issue. Please find the below cron entry.
* * * * * root /root/scripts/test.script > /root/scripts/test.log 2>&1
Any suggestions will be appreciated.