1838576 Members
4208 Online
110128 Solutions
New Discussion

Cron job

 
hpuxhelp
Regular Advisor

Cron job

Can some1 please help me on how to write a simple cron job that will email to personA every day every hour for 30 days until it hits an errors and it can't email that person anymore...
3 REPLIES 3
Alex Richardson
Advisor

Re: Cron job

This doesn't really have enough information to give a good response. It would seem more likely that you would want your script to verify something and email you if there are problems, unless you are trying to write something to spam someone.

My main question is are you emailing a local user, either on the system with the cron script, or in the same buisness area of control. If so, you are going about things a little strangely and may want to think about a different approach.

Another thing is that cron is not going to stop, meaning it will continue to run as an activity/process till you remove the cron entry. Nor will it stop transmitting emails to personA if there are errors, if the mail can be sent and leave you host, then thats all she wrote... If anything you will get a "bounce-back" email replied to the sender.

Please rethink/rephrase your question a little because it really sounds like you are trying to setup a spam to annoy someone, if I am completely off base I do apologize.
hpuxhelp
Regular Advisor

Re: Cron job

oh no... that is not what i am trying to accomplish
we're trying to pin point a problem that currently happen on our host. Users report that the mailx doesn't work when they run a certain applications. We have tried to use mailx to send out / receive form internal and external, and we see no problems. That is why I want to write a script to send an email of testing to a developer testign for that application every day for a week or so, so that we can prove that the mailserver is working properly...and it is their application that needs to get attention.
And that is what I am trying to do...bc i don't know how to write cron...
So.it is not what you think at all...
Bill Hassell
Honored Contributor

Re: Cron job

You can show every email that went out by simply reading /var/adm/syslog/mail.log where all email (incoming or outgoing) is logged. The command mailq on HP-UX will show any mail trasnsmitted but could not be completed. The user that sent the email will receive an error email if the delivery could not be completed.

If you just want to send a message every hour then the cron entry would be:

5 * * * * /usr/bin/mailx -s "test message" name@computer.com < /etc/issue

This will send the contents of the /etc/issue file to the email address name@computer.com 24 times each day forever. Any failures that bounce back will be stored in the sender's email. Any emails that are deleted along the way (*very* likely due to anti-spam filters) will not be traceable. All you can do is look at the log which is proof that the message was sent out (assuming no errors logged).


Bill Hassell, sysadmin