On Sun, 20 Feb 2000, Rogier Maas wrote:
Hi,
I want to mail a file to someone from a cronjob. How would I do that?
It's a cronjob starting every day at 00:00, creating a backup file. After the backup, I want to mail the created file to myself (on another host).
Ooh! I know this one! :) Have a look at my backup script for my one and only MySQL database (I'm particularly proud of this): #!/bin/sh # Script to create daily backups of the IRM database mysqldump -u root -ppassword irm > /tmp/irm-`date '+%y%m%d'`.dump # Makes an sql dump of the irm database in /tmp gzip /tmp/irm-`date '+%y%m%d'`.dump # Compresses the file IRM_BACKUP=irm-`date '+%y%m%d'`.dump.gz ; export IRM_BACKUP # Less typing down the road ;) mv /tmp/$IRM_BACKUP /home/jpennington # Moves the file to a remote location chown jpennington.users /home/jpennington/$IRM_BACKUP chmod 600 /home/jpennington/$IRM_BACKUP # Makes the file irmadmin's property echo "$IRM_BACKUP has been created" | mail jpennington -s $IRM_BACKUP # Notifies user that the cron job terminated successfully # EOF I'm also fishing for some suggestions concerning the script in general. I need to integrate some error-trapping with this, since my script will go merrily about it's business wether the file was created or not. Ideas? :) -- -=|JP|=- Jon Pennington | Atipa Linux Solutions -o) jpennington@atipa.com | Kansas City, MO /\\ 816-241-2641 x107 | http://www.atipa.com _\_V -- To unsubscribe send e-mail to suse-linux-e-unsubscribe@suse.com For additional commands send e-mail to suse-linux-e-help@suse.com Also check the FAQ at http://www.suse.com/Support/Doku/FAQ/