Cron does not work

Asked

Viewed 192 times

0

I’m trying to run a file .sh to perform a backup of my database, but for some reason the cron to run this file is not working.

I’ve tried to make a lot of changes, but nothing works. All other cron work normally except this one should run my DB backup file.

Note: The file works and generates a backup of DB normally when running on the command line.

Just follow my code:

#!/bin/bash
# mobcliDB_bkp.sh
DATA=$(date '+%d-%m-Y-%T')
NOME="/root/data/mobcliDB_bkp-$DATA.sql"

HOST="localhost"
USER="root"
PASSWORD="*******"
DATABASE="mobcliDB"

/usr/bin/mysqldump -h $HOST -u $USER -p$PASSWORD $DATABASE > $NOME

zip -r /root/data/mobcliDB_bkp-$DATA.zip $NOME

rm /root/data/mobcliDB_bkp-$DATA.sql 

The cron is like this:

*/5 * * * * /meu diretorio/mobcliDB_bkp.sh

I have other cron in the same file that work normally.

  • If you turn the remote manually, it works?

  • @Gabrielsantos Running manually works normal!

  • is to run every 5 minutes?

  • @Gabrielsantos When it works, I will put to run 1 time a day, but for now I left every 5 minutes to test and see if it is working.

  • Can be the zip that is not being recognized. Try to put the absolute path to it.

  • It’s probably a permission issue. Is the script accessible and executable to the user you’re enabling crontab on? Check the cron logs in /var/log/cron and see what might be wrong.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.