Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Job (Automysqlbackup) help 1

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
I am trying to run a Cron job on my website. Its going to create a backup of my MySQL database. I contacted my webhosting support and they "fixed it" for me, but it still wasn't working. So I just overwrote it with what I thought was broken but they may have changed some other things without telling me. They changed my Cron Job to run this command:
Code:
cd ; ./public_html/support/automysqlbackup.sh ;
I am using a windows system (and haven't dove into *nix at all) so Im guessing...
cd = current directory (?)
; - command delimeter
then script to run.
I have the cron job running every other minute (for testing purposes. Right now I am getting
/bin/sh: ./public_html/support/automysqlbackup.sh: /bin/sh
: bad interpreter: No such file or directory
and before I got this email:
mkdir: cannot create directory `/support': Permission denied
mkdir: cannot create directory `/support': Permission denied
mkdir: cannot create directory `/support': Permission denied
mkdir: cannot create directory `/support': Permission denied
touch: creating `/support/backups/localhost-925139000.log': No such file or directory
./public_html/support/automysqlbackup.sh: line 397: /support/backups/localhost-925139000.log: No such file or directory
touch: creating `/support/backups/ERRORS_localhost-926082000.log': No such file or directory
./public_html/support/automysqlbackup.sh: line 401: /support/backups/ERRORS_localhost-926082000.log: No such file or directory ======================================================================
AutoMySQLBackup VER 2.5

Backup of Database Server - ======================================================================
Backup Start Time Fri Jul 21 13:30:02 CDT 2006 ======================================================================
mkdir: cannot create directory `/support': Permission denied
mkdir: cannot create directory `/support': Permission denied Daily Backup of Database ( db_name ) Rotating last weeks Backup...

./public_html/support/automysqlbackup.sh: line 408: /support/backups/daily/db_name/db_name_2006-07-21_13h30m.Friday.sql: No such file or directory
gzip: /support/backups/daily/db_name/db_name_2006-07-21_13h30m.Friday.sql: No such file or directory

Backup Information for /support/backups/daily/db_name/db_name_2006-07-21_13h30m.Friday.sql
gzip: /support/backups/daily/db_name/db_name_2006-07-21_13h30m.Friday.sql.gz: No such file or directory
----------------------------------------------------------------------
Backup End Fri Jul 21 13:30:02 CDT 2006
======================================================================
Total disk space used for backup storage..
Size - Location
du: `/support/backups': No such file or directory


======================================================================
If you find AutoMySQLBackup valuable please make a donation at
======================================================================
(note db_name replaced with personal info)
I am using sitegrounds as my webhosting company if it helps.
I apprecaite all the help in advance.
 
cd = Change Directory. Without any argument, it will change to your "$HOME" directory (as defined in /etc/passwd for your USER-ID).

The "Bad Interpreter" message indicates that they do not have /bin/sh present (or you have no permissions to run it). It could be you need /bin/bash, or /sbin/sh, or several other possibilities.

Your script requires the "support" sub-directory. That directory probably doesn't exist, and your account doesn't have permissions to create it. Once that fails, the remainder of your error messages are caused by the missing sub-directory.

"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
I talked to some tech support at sitegrounds and they reccommended this instead:
Code:
sh public_html/support/automysqlbackup.sh
However now I am getting an output of:
public_html/support/automysqlbackup.sh: line 26:
: command not found
public_html/support/automysqlbackup.sh: line 29:
: command not found
public_html/support/automysqlbackup.sh: line 32:
: command not found
public_html/support/automysqlbackup.sh: line 35:
: command not found
public_html/support/automysqlbackup.sh: line 38:
: command not found
public_html/support/automysqlbackup.sh: line 41:
: command not found
public_html/support/automysqlbackup.sh: line 49:
: command not found
public_html/support/automysqlbackup.sh: line 52:
: command not found
public_html/support/automysqlbackup.sh: line 55:
: command not found
public_html/support/automysqlbackup.sh: line 56:
: command not found
public_html/support/automysqlbackup.sh: line 60:
: command not found
public_html/support/automysqlbackup.sh: line 63:
: command not found
public_html/support/automysqlbackup.sh: line 66:
: command not found
public_html/support/automysqlbackup.sh: line 69:
: command not found
public_html/support/automysqlbackup.sh: line 72:
: command not found
public_html/support/automysqlbackup.sh: line 75:
: command not found
public_html/support/automysqlbackup.sh: line 78:
: command not found
public_html/support/automysqlbackup.sh: line 81:
: command not found
public_html/support/automysqlbackup.sh: line 84:
: command not found
public_html/support/automysqlbackup.sh: line 87:
: command not found
public_html/support/automysqlbackup.sh: line 90:
: command not found
public_html/support/automysqlbackup.sh: line 93:
: command not found
public_html/support/automysqlbackup.sh: line 96:
: command not found
public_html/support/automysqlbackup.sh: line 338:
: command not found
public_html/support/automysqlbackup.sh: line 350:
: command not found
public_html/support/automysqlbackup.sh: line 407: syntax error near unexpected token `{ '
public_html/support/automysqlbackup.sh: line 407: `dbdump () { '

lines 24-38 are:
Code:
# Username to access the MySQL server e.g. dbuser
USERNAME=aspexent_root

# Username to access the MySQL server e.g. password
PASSWORD=aspexpos

# Host name (or IP address) of MySQL server e.g localhost
DBHOST=localhost

# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="all"

# Backup directory location e.g /backups
BACKUPDIR="/"
any ideas?
 
Does you script contain DOS-type line termination (CR/LF)?
You said you were a Windows guy, so if you created (or just loaded and saved) this file using Notepad or some other DOS/WIN utility, then there is a good chance each line ends with CR/LF.
Those lines you show in your post look fine to me. They are just comment lines (starting with #) and others that set variables which are likely used later in the script.

Can you post the first 30 or so lines of your script?


"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Code:
#!/bin/sh
#
# MySQL Backup Script
# VER. 2.5 - [URL unfurl="true"]http://sourceforge.net/projects/automysqlbackup/[/URL]
# Copyright (c) 2002-2003 wipe_out@lycos.co.uk
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#=====================================================================
#=====================================================================
# Set the following variables to your system needs
# (Detailed instructions below variables)
#=====================================================================

# Username to access the MySQL server e.g. dbuser
USERNAME=user

# Username to access the MySQL server e.g. password
PASSWORD=pass

# Host name (or IP address) of MySQL server e.g localhost
DBHOST=localhost

# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="all"

# Backup directory location e.g /backups
BACKUPDIR="/"

# Mail setup
# What would you like to be mailed to you?
# - log   : send only log file
# - files : send log file and sql files as attachments (see docs)
# - stdout : will simply output the log to the screen if run manually.
# - quiet : Only send logs if an error occurs to the MAILADDR.
MAILCONTENT="quiet"

# Set the maximum allowed email size in k. (4000 = approx 5MB email [see docs])
MAXATTSIZE="4000"

# Email Address to send mail to? (user@domain.com)
MAILADDR=""
Line 25 is # Username
Line 26 is USERNAME=
 
Does this work if you run it interactively? If so, it could be that you need to include whatever variables are set when running interactively ($PATH etc) at the start of your script since cron runs in it's own (very limited) environment otherwise.
 
Since you are getting the error on the very first non-comment line, I'm pretty sure the problem is in line termination. See if the UNIX box has a DOS to UNIX conversion utility (dos2unix, dtox, (etc)).

Check this thread for other ways to remove the Carriage Returns:

thread822-721705


"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top