script for sending log files daily
I don't know any BASH although I will be learning it this fall at college. I am trying to find a script that will send a log file daily using sendmail to a specified email address. I have sendmail installed and working I'm just not exactly sure how to write a script that will send a file as an attachment and do it once a day.
If anyone knows how to do this, I would be very grateful. Also, once I get this script do I just put it in /etc/init.d/ folder? Thanks a lot! |
Here's what you need to do: 1. Run the command that will actually email the attachment and make sure it works. 2. Create a bash file that will run that command and make sure the bash script works. 3. Add the bash script to a cron.
|
Quote:
I hate having to ask to be spoonfed, but I really am new to the linux environment (been using windows all my life unfortunately). I can figure out the command to email attachments, I won't ask for that, but I really have no idea what a "cron" is. How would I add the .sh file to the cron? Thanks again |
Quote:
Code:
man cron # explains what cron is Code:
/usr/sbin/sendmail "user@domain" << EOF |
Thanks for your help guys, I got it working perfectly.
Just for reference for anyone else looking for answers here is my script: Code:
#!/bin/bash And the cron solution for me was to just drop this script in the /etc/cron.daily/ folder. |
I'm glad you got it working. Looks like your on your way to becoming a Linux admin. You can also create a cronjob, as root run:
crontab -e This way you can run the script every minute, every week or whenever you want. Do some brainstorming on cron and you'll be able to schedule any script. It is a very powerfull admin tool. |
All times are GMT -5. The time now is 10:38 AM. |