bcornele
asked on
Sending a message that includes a text file to an IMAP server every 30 minutes
I would like to know how to automate and build a script that will send a text file as an email to a user(s) ever 30 minutes. I have the following simple script that builds a simple text file....
while true
do
processname >> processtxt
sleep 1800
done
I execute this with the nohup option and use the & parameter.
I would now like to mail the processtxt file to an email recipient every 30 minutes.
Help would be greatly appreciated.
BC
while true
do
processname >> processtxt
sleep 1800
done
I execute this with the nohup option and use the & parameter.
I would now like to mail the processtxt file to an email recipient every 30 minutes.
Help would be greatly appreciated.
BC
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
crontab -e
--- editor pops up
--- add following line:
0,30 * * * * processname | mail user@email
--- close file
And that's it. No need for additional file and script.
--- editor pops up
--- add following line:
0,30 * * * * processname | mail user@email
--- close file
And that's it. No need for additional file and script.
ASKER
While I am familiar with crontab, I am trying to keep this in a script I can execute from my home directory using the nohup command with the & arg. I rejected your answer because I needed script coding lines to compliment my existing script. Thanks. BC
ASKER
The pipe of the processtxt clued me in on how to pipe a chunk of data to mailx using the -s option with a subject line.
Here is the final script with your modifications.
while true
do
processname >> processtxt
mailx -s "Subject Line" user@domain.com < processtxt
sleep 1800
done
Thanks for you information and prompt repsponse to my question.
BC
Here is the final script with your modifications.
while true
do
processname >> processtxt
mailx -s "Subject Line" user@domain.com < processtxt
sleep 1800
done
Thanks for you information and prompt repsponse to my question.
BC
and also put a cron file for sending out the mail.
sivaran