crontab - Cron Job - How to send an output file to an email -
i have line in crontab:
* * * * * /var/www/dir/sh/mysql_dumb.sh | mail -s "mysql_dump" example@mail.com
(every minute sample)
so, works fine, email empty.
update:
the output mysql_dumb.sh *.sql
file , save file in directory.
how can send copy (*.sql file) output -> mysql_dumb.sh
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
if script reporting errors, may going stderr
, you're redirecting stdout
. can redirect stderr
adding 2>&1
command:
* * * * * /var/www/dir/sh/mysql_dump.sh 2>&1 | mail -s "mysql_dump" example@mail.example
Comments
Post a Comment