Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:17:04+00:00 2026-06-13T07:17:04+00:00

i want to run a cron job that back ups my mysql database and

  • 0

i want to run a cron job that back ups my mysql database and my wordpress files once a day from the hostgator cpanel.

i found a sample script and edited the parameters with my information but it doesn’t seem to be working properly. I don’t have much experience with cron jobs so i’m not sure what all my issues are.

i have the .sh file named, backups.sh, saved in the home directory and have a folder named backups with subfolders database and wordpress.

this is the .sh file. i replaced {my info} with my credentials and filled out everything for my database info:

#!/bin/bash
# Script Function:
# This bash script backups up the db everyday dependent on 
# when you set the cron job to run with a file name time stamp 
# and tar.gz zips the file.
# The db will be saved in /backups/database/
# Db backups older than 5 days will be deleted.\
#[Changes Directory]
cd /home/{my info}/backups/

#[Old DB Deletion and Files Script]
find /home/{my info}/backups/database -name "*.tar.gz" -mtime +5 -exec rm -f {};
find /home/{my info}/backups/wordpress -name "*.tar.gz" -mtime +5 -exec rm -f {};

#[Stamps the file name with a date]
TIMESTAMP=`date +%m-%d-%y-%H%M`

#[DB Backup Scripts]
# DB Name
HOST=localhost
DBNAME=""
USER=""
PASSWORD=""
DUMP_PATH=/home/{my info}/backups/database/
BACK_PATH=/home/{my info}/backups/wordpress/
mysqldump --opt -c -e -Q -h$HOST -u$USER -p$PASSWORD $DBNAME > $DBNAME.sql
tar czpf $DUMP_PATH/$DBNAME.$TIMESTAMP.tar.gz $DBNAME.sql

rm -f $DBNAME.sql
#Backing up WordPress files @ root
tar czf $BACK_PATH/wordpress.$TIMESTAMP.tar.gz /home/{my info}/public_html/mydomain

Here is what I have for the command line:

/bin/sh ~/backups.sh

i get an email after the cron job executes and it notifies me saying,
“No such file or directory”, along with a bunch of command not found.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:17:05+00:00Added an answer on June 13, 2026 at 7:17 am

    cron does not always have the same PATH variable as your login shell, and therefore cannot always locate the executable for things like mysqldump or even tar.

    I recommend using the full path to each command, ie: /usr/bin/mysqldump instead of just mysqldump. You can easily determine what the path is by using the which command.

    $ which mysqldump
    /usr/bin/mysqldump
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a PHP script that will run as a cron job
I want to run a cron job every minute that will launch a script.
I want to run a cron job that does cleanup that takes a lot
I have a cron job that ideally I want to run hourly (it's on
I want to get the details of the last run cron job. If the
I want to set up a cron job to run a python script, but
I want to set up a cron job. The job has to run every
I want to create cron job that runs a script every 5 seconds. Seeing
How can i run an cron job from php, and the cron to start
I have a script that I'm trying to run from cron. When I run

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.