Creating a cron job to email me a txt file/format?
I'm new to Cron Jobs... but I would like to try something to make it a little easier on myself here at work.
I have a template that I use that's in txt /text file. It looks like this: Backup Group name1 via Legato: - Backup Group name2 via Legato: - Backup Group name3 via Legato: - etc.. It is only 15 groups so it's not a big file persay just long. I check the status of my backups and then log it as successful or not... 99% they are. I would like to create a cron job so that it has this template in it and can simply email me everyday M-F this template so that way I can just fill it in, save it and be done. I am currently running Fedora 7 on my pc. Thanks for the help in advance, -Nigel |
maybe something like this (or a script that cron uses and then you do the "legwork" in the script)
Code:
0 8 * * 1-5 cat /path/to/template.txt | mail -s "Backup Template" nigel@example.com Hope this helps. |
The program to send yourself (or anyone else) mail from stdout is called "mail" although that's really an alias for mailx on my system. Any cron job not directed to /dev/null should send you a mail automatically. If you want to limit your output, you can put the mail pipe in the script you're running:
Code:
#!/bin/sh Joel |
Thanks guys.
I have never written a script before sooo... I don't know how to do that. I have heard or RSYNC but never used it so I have no clue how it even works... :-( This is a silly question but where do I put the cron job or how do I start it? Is the path that I must take for the cron job /dev/null ? Still trying to learn as much as possible about linux :-) Thanks again, -Nigel |
if it is to be run as a particular user (yourself) then use the command crontab -e (to edit your crontab) and add the example i provided (or whatever works for you based on your review of the manual page).
this places it in /var/spool/cron/<your-user> (for example) if you want it to run from "the system" (as root from one of the /etc/cron.* directories) it is similar in syntax but you can consult the other cron-jobs in the /etc/cron.* directories for examples. I suggest using a non-root user if it is not something that needs root privileges to perform (and this doesn't sound like it does) |
Nice desc/tutorial about cron: http://www.adminschoice.com/docs/cro...Crontab%20file
BTW, always use the full/absolute paths to all cmds you use in a cron script, as the cron env is extremely minimal. |
Quote:
definetely a good practice to use absolute path as chrism01 noted. |
Quote:
Here's a Quick Synopsis: Open a text editor (man vi; man emacs). Enter the text. Save the file. Change the permissions (man chmod) to executable. Enter the script's name on the command line. I'm bein' real with you man: it's not hard. Getting over that self-defeating belief is the biggest step toward computing empowerment. Quote:
Quote:
Quote:
Code:
echo "beer beer beer cheese" >> /dev/null Quote:
|
All times are GMT -5. The time now is 11:45 PM. |