Issue
I have a bash script that grabs a file from an FTP, unrars it, inserts it into a MySQL db and then does a few queries on that database. Now the script runs perfectly when i manually run it but I need it to be ran every day at a certain time. So of course i put it in a cron job. Now I know that the cron is running because at the end of the script i have it echo a line to a log file and it has been doing that. However, MySQL commands are not being done in the script.
Basically it will grab the file from the ftp, and unrar it, then not load the file or do the mysql commands, and then it moves the file to a different directory and does my log echo.
TLDR: My bash script that contains bash commands and MySQL will only do the bash commands when put in a cron. Will do all commands when ran manually.
Solution
Are you confident that the script runs as the same user when you run it on the command line and when it gets run by the cron job? Most likely not, most likely not even the same group.. You may need to adjust your script to sudo to some other user, and to check the environmental variables..
Answered By - George M Reinstate Monica