FG
💻 Software

Shell script of mysqldump works fine when run manually, but does not run in the cron job?

Fresh5 days ago
Mar 15, 20262541 views
Confidence Score0%
0%

Problem

I have a shell script to get a MySQL database dump. This script works fine when run manually But when I include this script to be run in cron job, it doesnt make the backup. This is what I included in the cron job: What am I missing here?

Error Output

#!/bin/sh
fqn=/home/Mysqluser/daily_dumps/bookstore_`date +%Y%m%d_%H%M%S`.sql.gz
mysqldump -u root -h localhost -pmysql#passwd bookstore | gzip > $fqn

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Shell script of mysqldump works fine when run manually, but does not run in the cron job?

Low Risk

It's probably because the environment(s) (type at prompt to see it) are different. I had similar problem trying to run a mysql query in cron.daily, I solved it by adding this flag It look like mysqldump has a similar flag (needs to be first argument…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment