Skip to main content
Bounty Awarded with 50 reputation awarded by cj333
added 510 characters in body
Source Link
Emmanuel
  • 4.3k
  • 2
  • 26
  • 31

Force the PATH in your script, cron may not provides the same path as the one you have in a terminal session.

EDIT:
In a terminal get your PATH:

env | grep "^PATH="   
PATH=/sbin:/usr/sbin:/usr/local/sbin:...   (you will have different value

Cut and paste that line in your script just bellow the #!/bin/bash

#!/bin/bash

PATH=/sbin:/usr/sbin:/usr/local/sbin:     (put your path 
export PATH

(thats just for instance)

There may be other variable to add in your script; look for variable which names contain the 'MYSQL' string with env | grep MYSQL and set | grep MYSQL

Force the PATH in your script, cron may not provides the same path as the one you have in a terminal session.

Force the PATH in your script, cron may not provides the same path as the one you have in a terminal session.

EDIT:
In a terminal get your PATH:

env | grep "^PATH="   
PATH=/sbin:/usr/sbin:/usr/local/sbin:...   (you will have different value

Cut and paste that line in your script just bellow the #!/bin/bash

#!/bin/bash

PATH=/sbin:/usr/sbin:/usr/local/sbin:     (put your path 
export PATH

(thats just for instance)

There may be other variable to add in your script; look for variable which names contain the 'MYSQL' string with env | grep MYSQL and set | grep MYSQL

Source Link
Emmanuel
  • 4.3k
  • 2
  • 26
  • 31

Force the PATH in your script, cron may not provides the same path as the one you have in a terminal session.