Link to home
Start Free TrialLog in
Avatar of Nathan Riley
Nathan RileyFlag for United States of America

asked on

CRON Job Keeps Failing

mysqldump -u root -ppassword theipb | gzip -c > /home/domain/public_html/_db_backups/$(date "+%Y%M%d%H%m").theipb.sql.gz

The above command runs fine from ssh, but when added as a cron job on simple control panel it never completes.  Is there a syntax error in it for the control panel?
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjagdis
mjagdis

Unescaped '%'s are converted to newlines and everything after the first is sent to the command as standard input. See the man page for crontab(5).
For crontab jobs to run successfully, and in your case, please do the following:

create a shell script file
set required env variables in it (or you may source a .profile file using . /path/to/.profile)
add the above command to it (use full pathnames for command, etc)
make the script executable
add it as a crontab job by referring to its full pathname

you may read the crontab log file to check for error messages , or you mar redirect standard error to a file ( 2> /path/to/mylogfile)
you may use >> & 2>> for redirection of output and standard error rather than > & 2> to accumulate output and error messages
Make sure you define your PATH var in your crontab to ensure the.binaries are found