Quote:
Originally Posted by Zero187
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?
|
A good reason to read man pages:
Code:
man cron # explains what cron is
man 1 crontab # explains how crontab works
man 5 crontab # explains the format of the crontab entries
Regarding the sendmail issue, you can embed the log file in the mail body using command substitution and a "here document". For example:
Code:
/usr/sbin/sendmail "user@domain" << EOF
From: Me <user@domain>
To: Mario Rossi <user@domain>
Cc: Luigi Bianchi <user@domain>
Subject: Test subject. Today is $(date)
The content of today log file is:
$(cat /path/to/log/file)
Goodbye
EOF
If you want to attach it, use uuencode or mutt. They have an option to attach files. Once you've finished and tested the script, be sure to use the full path of each command inside the script (crontab has a very limited environment and the PATH is just /bin:/usr/bin). Also check for standard output and standard error in the mail box of the crontab's owner, since every stdout and stderr not redirected to a file is sent through the system mail by default.