[rhn-users] syntax of my cronjob
Donald Lambert
donald.lambert at dal.ca
Thu Sep 8 13:52:44 UTC 2005
Nick,
You could just use the MAILTO option in cron and do not redirect any output
MAILTO=kvetch at gmail.com
0 5 * * * /opt/app/cron/runjob.sh
Of course this would not give you the same subject line, but it is a bit
cleaner. Also it would trap \
stderr and send it to you as well should anything go wrong in your script.
-- Donnie
Kvetch wrote:
> Hello, I am having some issues with a script I have in my cron. I
> have a script that when it runs I would like to write out its output
> to the screen into a file and then mail the contents of that file to
> myself. The script takes about 2-5 minutes to finish processing.
>
> If I run the following a couple times I notice that it is actually
> emailing the contents of the file before it finishes running the job
> and if the job had run earlier then it sends me the contents of the
> file the last time it ran.
> #/opt/app/cron/runjob.sh > /opt/app/cron/runjob.out |cat
> /opt/app/cron/runjob.out | mail -s "Job Output" me at gmail.com
> <mailto:me at gmail.com>
>
> So I added a rm command in the beginning thinking that this would
> help. But it now sends out a blank email.
> 0 5 * * * rm /opt/app/cron/runjob.out | /opt/app/cron/runjob.sh >
> /opt/app/cron/runjob.out |cat /opt/app/cron/runjob.out | mail -s "Job
> Output" me at gmail.com <mailto:me at gmail.com>
>
> So basically how can I write out the output of the script and email it
> also while making sure it emails the contents of the file after the
> job has been run? I need it to write out the file so I have access to
> it for the entire day until the next time the cronjob runs.
> I know my syntax is really poor so if anyone has any thoughts on how
> to clean it up I would appreciate it.
>
> Thanks,
> Nick
>
>------------------------------------------------------------------------
>
>_______________________________________________
>rhn-users mailing list
>rhn-users at redhat.com
>https://www.redhat.com/mailman/listinfo/rhn-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/rhn-users/attachments/20050908/5c140947/attachment.htm>
More information about the rhn-users
mailing list