I have this line in crontab:
* * * * * /var/www/dir/sh/mysql_dumb.sh | mail -s "mysql_dump" [email protected]
(every minute only a sample)
So, all works fine, but the email is empty.
UPDATE:
The output from mysql_dumb.sh is a *.sql
file and they save the file in a directory.
How can I send a copy (*.sql file) from this output -> mysql_dumb.sh
to my email?
mysql_dumb.sh:
#!/bin/bash PATH=/usr/bin:/bin SHELL=/bin/bash /usr/bin/mysqldump -u USER -pPASS DATABASE > /var/www/dir/backup/backup_DB_`date +%d_%m_%Y`.sql
Run `mail' command by '-s' option with email subject and the recipient email address like the following command. It will ask for Cc: address. If you don't want to use Cc: field then keep it blank and press enter. Type the message body and press Ctrl+D to send the email.
Like most daemons running on our system, the cron daemon logs its output somewhere under /var/log.
It is a wildcard for every part of the cron schedule expression. So * * * * * means every minute of every hour of every day of every month and every day of the week .
If the script is reporting errors, they may be going to stderr
, but you're only redirecting stdout
. You can redirect stderr
by adding 2>&1
to the command:
* * * * * /var/www/dir/sh/mysql_dump.sh 2>&1 | mail -s "mysql_dump" [email protected]
From a crond perspective more accurate is to place in to your cron:
[email protected] * * * * * /var/www/dir/sh/mysql_dumb.sh * * * * * /var/www/dir/sh/other.sh * * * * * /var/www/dir/sh/other2.sh
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With