There is probably a better way of doing this, but I’m going to start with the hard way and then hopefully make it better as I go.
I want a simple script to run a command and email me the results – cool.
I need to ensure that email is going to work from my hosts, so this is editing the /etc/mail/sendmail.mc
dnl define(`SMART_HOST', `smtp.your.provider')dnl
to
define(`SMART_HOST', `smtp.nsw.exemail.com.au’)dnl
some more hacking in this file, this was handy: http://www.phase2.net/2007/03/sendmail-on-rhel-40-without-dns/
then try and run make from /etc/mail on my OEL 5 machine, get:
[root@E1ENT2 mail]# make
WARNING: 'sendmail.mc' is modified. Please install package sendmail-cf to update your configuration.
WARNING: 'submit.mc' is modified. Please install package sendmail-cf to update your configuration.
need to install some packages
Follow instructions on public yum server: http://shannonscncjdeblog.blogspot.com.au/2012/06/public-yum-server.html sweet
yum search *send*
[root@E1ENT2 mail]# yum search *send*
Loaded plugins: rhnplugin, security
This system is not registered with ULN.
ULN support will be disabled.
======================================================= Matched: sendmail.cf ========================================================
sendmail.x86_64 : A widely used Mail Transport Agent (MTA).
sendmail-cf.x86_64 : The files needed to reconfigure Sendmail.
ok, now
make
now restart sendmail
service sendmail restart
Great, so now we can script and get emails that things are being done, nice!
mail -s test name@domain.com < /dev/null 2>&1 >> /dev/null
See from above, we can send files to ourself!
So, a script to restart JDE, ohh – so many ways!
I decided on the following
#!/usr/bin/ksh
USERNAME=`whoami`
if [ $USERNAME = 'jde91' ]
then
#we are JDE
$EVRHOME/system/bin32/EndOneWorld.sh > /tmp/EndOneWorld.out
sleep 15
$EVRHOME/system/bin32/RunOneWorld.sh >> /tmp/EndOneWorld.out
sleep 15
ps -ef |grep jdenet >> /tmp/EndOneWorld.out
porttest JDE XXXXX DV910 >> /tmp/EndOneWorld.out
df -k >> /tmp/EndOneWorld.out
mail -s 'E1 restart complete' shannon.moir@myriad-it.com < /tmp/EndOneWorld.out 2>&1 >> /dev/null
else
echo "File not there"
fi
This was saved, then in created an EM12C job to run it. This was running at jde91
. /home/jde91/.bash_profile; $EVRHOME/system/bin32/restartJDE.ksh