crontab with mysqldump issue

I'm having an issue with an automatic mysqldump using cron. I have written the following (what I think) is very simple bash script. The database is very small and simple, and I already have automatic backups setup, I am just using this mysqldump as an extra backup.

mysqldump -u username -ppassword database_name > /root/mysql_backup/PIS_Backup

So the issue is, that when I run this bash script everything happens just as normal, a file is created called PIS_Backup. However, when I run it through cron it creates the file, but the file is empty. The cron entry looks like this.

0 0,12 * * * /root/mysql_backup/backup

Thanks in advance.
3. set PATH env variable in crontab. By default PATH is /usr/bin:/bin according to man 5 crontab
As mentioned, either set the PATH in the crontab, set the PATH in the script, or use full pathnames in your script.

Alternatively, if it's a single line like that, just put it directly into the crontab.

I got the exactly the same problem :(
Can you please explain the exactly details to fix it, please?
It's very important for me
Well it is told in the above comments what to do.


edit the script so that the script can find mysqldump outside its normal PATH like /usr/bin/ /bin /usr/sbin and /sbin
it would look like the following.
/usr/local/bin/mysqldump -u username -ppassword database_name > /root/mysql_backup/PIS_Backup

or do not call a script and let cron do it all on its own!
It is one command so cron could do it on its own.
0 0,12 * * * root /usr/local/bin/mysqldump -u username -ppassword database_name > /root/mysql_backup

or make sure cron can find /usr/local/bin

edit the crontab file
If you open the crontab file you will see the following lines

So add /usr/local/bin to it

The choice is yours :D

So if i add /usr/local/bin/ in PATH at crontab i don't need the real path of mysqldump and can use MYSQLDUMP=$(which mysqldump) so via which command and that works?
Again: leave /etc/crontab alone. It's the system crontab. Use the root crontab (crontab -e) for your own alterations.
I will not instruct people any more to alter the /etc/crontab file. :r

MYSQLDUMP=$(which mysqldump)
if you are using the above, then you cannot ad that in the crontab line.
This is for a script.

Can you post your mysqldump script. (make sure the password is not copied along).