Re: Help with Crontab script?
- From: Ogre <rossz@xxxxxxxxx>
- Date: Tue, 30 Oct 2007 15:25:58 -0700
robert wrote:
Hello, I'm rather new to linux and was wondering if someone could
assist me in writing a crontab?
I want to tar a file daily and send it to an email address.
I think I can figure out how to write a crontab to tar the file daily
but how do I write one to email it as an attachment daily? I haven't
quite figured out email in linux yet.
Thanks for any help.
The simplest way to send an email with an attachment from a script is to use "mutt". For example (watch for wrapping!):
echo "File is attached" | mutt -s "Daily Report" -a /tmp/report.tar.gz someone@xxxxxxxxxxxxx
If you don't want a text body, you still need the echo:
echo | mutt ........
So the whole script is pretty damn simple:
--------------------------
#!/bin/bash
tar czf /tmp/report.tar.gz /path/to/the/file.txt
echo "report" | mutt -s "report" -a /tmp/report.tar.gz self@xxxxxxxxxx
--------------------------
Warning, example is untested and needs some customization, anyway.
--
Ogre
.
- References:
- Help with Crontab script?
- From: robert
- Help with Crontab script?
- Prev by Date: Samba acl problem when change from Windows always other sets to rwx
- Next by Date: hot sell nike jordan puma prada sandal......www.nikejordanaaa.com
- Previous by thread: Help with Crontab script?
- Next by thread: Re: Help with Crontab script?
- Index(es):
Relevant Pages
|