Cron Job Error: syntax error near unexpected token `('

juliep

Registered
Sep 29, 2014
3
0
1
cPanel Access Level
Website Owner
Hi I have created a cron job via my websites cPanel to backup our mySQL database each week using mysqldump, but I keep getting the following error via my email notification and I can not figure out what the problem is with the command line syntax. The only thing I can think of is there is a '(' character within my password string - could this be causing the problem?

The error received is:
/usr/local/cpanel/bin/jailshell: -c: line 0: syntax error near unexpected token `('
/usr/local/cpanel/bin/jailshell: -c: line 0: `/usr/bin/mysqldump -u myusername -pPassword123](8 mydatabasename > /home/sitefolder/backups/weeklybackup.sql'

Any help is much appreciated :)

Julie
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello :)

I suggest setting up a script that completes the database backup, and then simply execute that script in the cron job. It's not a good idea to pass a password in plaintext via a cron job. This is an older thread, but it will give you an idea of how you can accomplish this:

Backup databases through cron job

Thank you.