2

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/myFile.sh: line 2: /var/www/vhosts/domain.com/subdomains/techspatch/installation.sql: Permission denied" NOTICE: it's just line 2... it writes to the local server just fine.

Below is the Bash File:

    #!/bin/bash
mysqldump -uUSER -pPASSWORD -hHOST dbName> /var/www/vhosts/domain.com/subdomains/techspatch/installation.sql

mysql -uadmin -pPASSWORD -hlocalhost dbName< /var/www/vhosts/domain.com/subdomains/techspatch/installation.sql

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

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • 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
  • 1
    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 –  Jan 21 '10 at 16:36

1 Answers1

1

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.

David Thornley
  • 181
  • 1
  • 1
  • 4