Crontab use

Moderator: Lillian.W@AST

Post Reply
cutedrake
Posts: 11
youtube meble na wymiar Warszawa
Joined: Wed Jan 13, 2021 10:23 pm

Crontab use

Post by cutedrake »

Hi, I would like to run a personal commande, to backup my mysql databases every night. So I use for that a script using a docker command like that (of course the variables are detailed in the script):
$DOCKER run -it mysql:5.7 /usr/bin/mysqldump -h $MYSQL_HOST -u $MYSQL_USER --password=$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/$DATE/$db.sql.gz

So, when I run the script by hand:

root@asustor:#./mysqlbackup.sh

It works wonderfully, but when I run it through a crontab command (in the crontab from crontab -e):
20 10 * * * /volume1/Backup/MySQL/mysqlbackup

I get empty files, as if the docker command did not work. Is it normal?
User avatar
Nazar78
Posts: 2004
Joined: Wed Jul 17, 2019 10:21 pm
Location: Singapore
Contact:

Re: Crontab use

Post by Nazar78 »

Share your full script without the mysql credentials. Probably you need to specify the full path of both docker and gzip as IIRC the path is not exported in cron, you need to export it manually.
AS5304T - 16GB DDR4 - ADM-OS modded on 2GB RAM
Internal:
- 4x10TB Toshiba RAID10 Ext4-Journal=Off
External 5 Bay USB3:
- 4x2TB Seagate modded RAID0 Btrfs-Compression
- 480GB Intel SSD for modded dm-cache (initramfs auto update patch) and Apps

When posting, consider checking the box "Notify me when a reply is posted" to get faster response
cutedrake
Posts: 11
Joined: Wed Jan 13, 2021 10:23 pm

Re: Crontab use

Post by cutedrake »

Thanks for the suggestion. In fact I found the mysqldump exec there:

"/usr/local/AppCentral/mariadb/data/binary/bin/mysqldump"

Thus not necessary to use a doker for that. And a simple line for using a bash script is enough.
lordtech
Posts: 9
Joined: Thu Dec 19, 2019 9:43 am

Re: Crontab use

Post by lordtech »

you may want try this:

Code: Select all

20 10 * * * sh /volume1/Backup/MySQL/mysqlbackup.sh
Post Reply

Return to “[Official] For AS52xx/53xx/66xx Series”