Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

good day, I have a bash script in my home directory that works properly from the command line (file structure is default media temple DV. < noted for certain permission issues) but receive this error from cron: "/home/ line 2: /var/www/vhosts/ Permission denied" NOTICE: it's just line 2... it writes to the local server just fine.

Below is the Bash File:

mysqldump -uUSER -pPASSWORD -hHOST dbName> /var/www/vhosts/

mysql -uadmin -pPASSWORD -hlocalhost dbName< /var/www/vhosts/

can't chmod from bash (lol, yeah i tried). writing the file there and setting the permissions before the transfer is useless...

i have googled the heck out of this situation and this one still seems unique.... any insight is appreciated

share|improve this question
please check with which permissions the file installation.sql is created when you execute the file manually and with which permissions when run from cron. – Christian Jan 20 '10 at 20:23
This might be a stupid question, but are you trying to run this from your crontab or a different users crontab? – Catherine MacInnes Jan 20 '10 at 20:36
thanks guys, i DID have to change permissions on my .sql file. Catherine, I appreciate the check, but i was originally trying to run from the user, but have successfully set everything through root. I was bale to get this problem resolved on my end, but will leave the thread open in case anyone has a sure fire solution to all these permission issues! PS: writing the file there and setting the permissions before the transfer was >not< useless – user32372 Jan 21 '10 at 16:36

Are there any environment variables that might be significant (maybe something MySQL pays attention to - I'm not really familiar with mySQL)? Remember that a cron job doesn't start with your environment, so you might need to define some in the bash script.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.