niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
· nixdoc.net · man pages · Linux HOWTOs · FreeBSD Tips · Forums
navigation Forum index » *nix » AIX
Cron job
Post new topic   Reply to topic Page 1 of 1 [12 Posts] View previous topic :: View next topic
Author Message
j3
*nix forums beginner


Joined: 07 Jun 2006
Posts: 23

PostPosted: Tue Jul 18, 2006 4:23 am    Post subject: Re: Cron job Reply with quote

connect wrote:
Quote:
Hi Guys,
Many many thanks to you all!
I appreciated immensely the prompt replies to get this issue resolved.....

Finally the quotes around the VARIABLES worked a treat - so now I can move
on.


I suspect that your problem is not solved at all. The quotes are
sensible but are now likely to be masking the problem which seems to be
that one or other of your variables is empty.
I recommend that you modify your cron job to include a line like
"uptime >>/tmp/mycron.log" and check the content of the file.
Best wishes,
Jeffrey
Back to top
connect
*nix forums beginner


Joined: 06 Apr 2005
Posts: 9

PostPosted: Mon Jul 17, 2006 12:46 am    Post subject: Re: Cron job Reply with quote

Hi Guys,
Many many thanks to you all!
I appreciated immensely the prompt replies to get this issue resolved.....

Finally the quotes around the VARIABLES worked a treat - so now I can move
on.

And Andreas I do know what your talking about - only if I thought of that
beforehand - bugger!! I was actually fixing an old script so it didn't
cross my mind.... Oh well, a good learning curve for me..

Have a fantastic day / week....
Until next time....... : )
"Andreas Schulze" <b79xan@gmx.de> wrote in message
news:1152877933.754540.88610@35g2000cwc.googlegroups.com...
Quote:
connect wrote:
[...]
# Checks system load at 15 minute intervals - emails if greater than 3
[...]

Any suggestions would be most appreciated

Cheers
Pedds : )

Hallo Pedds,

IMHO it is not neccessary at all to use cron together with a script to
send email to sbdy if system loads gets too high. What you try to
accomplish is already there thus no need to invent the wheel again. I
suggest that you might use Ressource Monitoring and Control (does this
name ring a bell Wink ? ) RMC that comes with AIX. Choose a suitable
event or create a new one, define a threshhold and let it send the
email to you (when the event is triggerd and/or when the condition
turns back to normal operation), let take apropriate counter measures
etc.

Regards,
andreas
Back to top
aix@mail.com
*nix forums addict


Joined: 21 Jul 2005
Posts: 86

PostPosted: Fri Jul 14, 2006 1:02 pm    Post subject: Re: Cron job Reply with quote

base60 wrote:
Quote:
aix@mail.com wrote:
base60 wrote:
connect wrote:

[...] snip

good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc

Sure, and it's a good practice to wash your hands frequently
as well.... and both have nothing to do with the OPs question.

Well, if you want to go that route... neither does your original
suggestion. cron will by default use whatever shell the user is defined
to use. If the script was executing properly in a shell, explicitly
defining the shell wont help any.

The if statement was failing because one of the variables was either
non numeric or null. Enclosing the variables in quotes as mentioned in
another post would be a useful suggestion, unlike your simply sarcastic
reply.
Back to top
Andreas Schulze
*nix forums beginner


Joined: 22 Feb 2005
Posts: 24

PostPosted: Fri Jul 14, 2006 11:52 am    Post subject: Re: Cron job Reply with quote

connect wrote:
Quote:
[...]
# Checks system load at 15 minute intervals - emails if greater than 3
[...]

Any suggestions would be most appreciated

Cheers
Pedds : )

Hallo Pedds,

IMHO it is not neccessary at all to use cron together with a script to
send email to sbdy if system loads gets too high. What you try to
accomplish is already there thus no need to invent the wheel again. I
suggest that you might use Ressource Monitoring and Control (does this
name ring a bell Wink ? ) RMC that comes with AIX. Choose a suitable
event or create a new one, define a threshhold and let it send the
email to you (when the event is triggerd and/or when the condition
turns back to normal operation), let take apropriate counter measures
etc.

Regards,
andreas
Back to top
Menno Willemse
*nix forums beginner


Joined: 15 Mar 2005
Posts: 42

PostPosted: Fri Jul 14, 2006 10:59 am    Post subject: Re: Cron job Reply with quote

connect wrote:
Quote:

The error comes back as follows:
/home/root/scripts/check_sysload[14]: test: 0403-004 Specify a parameter
with this command.

Well, the only "test" I can find is not on line 14, but anyway, if
either one of the variables ends up being empty, you will get this
error. You can avoid that by enclosing the variable names in double
quotes, like:

if [ "$SYSLOAD" -ge "$MAXLOAD" ]

However, neither variable is supposed to be empty anyway. Given that
"uptime" actually executes, maybe "something" happened to the output
format of uptime. To be more solid, maybe it's better to use sed rather
than cut:

/usr/bin/uptime \
| /usr/bin/sed 's/.*load average: \([0-9][0-9]*\).*/\1/' \
| read SYSLOAD

This will get you the first set of numbers after "load average: " which
I think is what you want.

Quote:
# Checks system load at 15 minute intervals - emails if greater than 3

#VARIABLES
SYSLOAD=`uptime | cut -d ":" -f 4|cut -d " " -f 2|cut -d "." -f 1`
MAXLOAD=3
TMPFILE=/tmp/sysload
HOSTNAME=`hostname`
EMAIL=

#MAIN
if [ $SYSLOAD -ge $MAXLOAD ] ; then

echo "Current system uptime " `uptime` > $TMPFILE
echo "\n\n Current high usage processes " >> $TMPFILE
ps auxwww | head >> $TMPFILE
echo "\n\n" >> $TMPFILE
ps -ef | sort +3 -r | head >> $TMPFILE
mail -s "High load on $HOSTNAME" $EMAIL < $TMPFILE
rm -f $TMPFILE
fi
Back to top
unixsystems@gmail.com
*nix forums beginner


Joined: 26 Jan 2006
Posts: 28

PostPosted: Fri Jul 14, 2006 10:21 am    Post subject: Re: Cron job Reply with quote

The syntax of the script is correct. It *must* be PATH related.

If the script couldn't find 'uptime' you'd get this message because
you'd be evaluating the '-ge' with with a null value.

connect wrote:
Quote:
Hi Guys,
Thanks heaps for your replies - unforutnately I have tried them all and
still getting the error....
Its weird as it runs beautifully on a 5.1 box - do you think it has
something to do with the AIX version?

I'm pulling my hair out! and that's not a pretty look

Cheers
Pedds : )
"base60" <nobody@whitehouse.com> wrote in message
news:v8Btg.53228$R26.43670@tornado.southeast.rr.com...
aix@mail.com wrote:
base60 wrote:
connect wrote:

[...] snip

good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc

Sure, and it's a good practice to wash your hands frequently
as well.... and both have nothing to do with the OPs question.
Back to top
connect
*nix forums beginner


Joined: 06 Apr 2005
Posts: 9

PostPosted: Fri Jul 14, 2006 5:05 am    Post subject: Re: Cron job Reply with quote

Hi Guys,
Thanks heaps for your replies - unforutnately I have tried them all and
still getting the error....
Its weird as it runs beautifully on a 5.1 box - do you think it has
something to do with the AIX version?

I'm pulling my hair out! and that's not a pretty look

Cheers
Pedds : )
"base60" <nobody@whitehouse.com> wrote in message
news:v8Btg.53228$R26.43670@tornado.southeast.rr.com...
Quote:
aix@mail.com wrote:
base60 wrote:
connect wrote:

[...] snip

good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc

Sure, and it's a good practice to wash your hands frequently
as well.... and both have nothing to do with the OPs question.
Back to top
base60
*nix forums Guru


Joined: 07 Sep 2005
Posts: 322

PostPosted: Fri Jul 14, 2006 12:00 am    Post subject: Re: Cron job Reply with quote

aix@mail.com wrote:
Quote:
base60 wrote:
connect wrote:

[...] snip

Quote:
good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc

Sure, and it's a good practice to wash your hands frequently
as well.... and both have nothing to do with the OPs question.
Back to top
Raff
*nix forums beginner


Joined: 26 Jul 2005
Posts: 5

PostPosted: Thu Jul 13, 2006 1:49 pm    Post subject: Re: Cron job Reply with quote

aix@mail.com has written:

Quote:
good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc

Isn't it enough to declare PATH variable in the beginning? I used to
write some scripts and copy paste all 'headers' including shell
definition, paths, work directories etc. Seems to be reasonable and
saves you some typing as well.

R.
Back to top
aix@mail.com
*nix forums addict


Joined: 21 Jul 2005
Posts: 86

PostPosted: Thu Jul 13, 2006 12:09 pm    Post subject: Re: Cron job Reply with quote

base60 wrote:
Quote:
connect wrote:
Hi,
I am running pSeries 615 AIX 5.2 and it seems to be having difficulty
running a script through the cron job.
i have manually run the script with success but cron gets stuck with the if
statement.
The error comes back as follows:
/home/root/scripts/check_sysload[14]: test: 0403-004 Specify a parameter
with this command.

here is the script:
# Checks system load at 15 minute intervals - emails if greater than 3

Explicitly define the shell used rather than accepting the default
used by cron

#!/usr/bin/ksh

etc.



#VARIABLES
SYSLOAD=`uptime | cut -d ":" -f 4|cut -d " " -f 2|cut -d "." -f 1`
MAXLOAD=3
TMPFILE=/tmp/sysload
HOSTNAME=`hostname`
EMAIL=

#MAIN
if [ $SYSLOAD -ge $MAXLOAD ] ; then

echo "Current system uptime " `uptime` > $TMPFILE
echo "\n\n Current high usage processes " >> $TMPFILE
ps auxwww | head >> $TMPFILE
echo "\n\n" >> $TMPFILE
ps -ef | sort +3 -r | head >> $TMPFILE
mail -s "High load on $HOSTNAME" $EMAIL < $TMPFILE
rm -f $TMPFILE
fi


Any suggestions would be most appreciated


Cheers
Pedds : )



good practice to explicitly define each executable as well...
/usr/bin/cut
/usr/bin/uptime .... etc
Back to top
base60
*nix forums Guru


Joined: 07 Sep 2005
Posts: 322

PostPosted: Thu Jul 13, 2006 2:51 am    Post subject: Re: Cron job Reply with quote

connect wrote:
Quote:
Hi,
I am running pSeries 615 AIX 5.2 and it seems to be having difficulty
running a script through the cron job.
i have manually run the script with success but cron gets stuck with the if
statement.
The error comes back as follows:
/home/root/scripts/check_sysload[14]: test: 0403-004 Specify a parameter
with this command.

here is the script:
# Checks system load at 15 minute intervals - emails if greater than 3

Explicitly define the shell used rather than accepting the default
used by cron

#!/usr/bin/ksh

etc.


Quote:

#VARIABLES
SYSLOAD=`uptime | cut -d ":" -f 4|cut -d " " -f 2|cut -d "." -f 1`
MAXLOAD=3
TMPFILE=/tmp/sysload
HOSTNAME=`hostname`
EMAIL=

#MAIN
if [ $SYSLOAD -ge $MAXLOAD ] ; then

echo "Current system uptime " `uptime` > $TMPFILE
echo "\n\n Current high usage processes " >> $TMPFILE
ps auxwww | head >> $TMPFILE
echo "\n\n" >> $TMPFILE
ps -ef | sort +3 -r | head >> $TMPFILE
mail -s "High load on $HOSTNAME" $EMAIL < $TMPFILE
rm -f $TMPFILE
fi


Any suggestions would be most appreciated


Cheers
Pedds : )

Back to top
connect
*nix forums beginner


Joined: 06 Apr 2005
Posts: 9

PostPosted: Thu Jul 13, 2006 1:36 am    Post subject: Cron job Reply with quote

Hi,
I am running pSeries 615 AIX 5.2 and it seems to be having difficulty
running a script through the cron job.
i have manually run the script with success but cron gets stuck with the if
statement.
The error comes back as follows:
/home/root/scripts/check_sysload[14]: test: 0403-004 Specify a parameter
with this command.

here is the script:
# Checks system load at 15 minute intervals - emails if greater than 3

#VARIABLES
SYSLOAD=`uptime | cut -d ":" -f 4|cut -d " " -f 2|cut -d "." -f 1`
MAXLOAD=3
TMPFILE=/tmp/sysload
HOSTNAME=`hostname`
EMAIL=

#MAIN
if [ $SYSLOAD -ge $MAXLOAD ] ; then

echo "Current system uptime " `uptime` > $TMPFILE
echo "\n\n Current high usage processes " >> $TMPFILE
ps auxwww | head >> $TMPFILE
echo "\n\n" >> $TMPFILE
ps -ef | sort +3 -r | head >> $TMPFILE
mail -s "High load on $HOSTNAME" $EMAIL < $TMPFILE
rm -f $TMPFILE
fi


Any suggestions would be most appreciated


Cheers
Pedds : )
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [12 Posts] View previous topic :: View next topic
The time now is Fri Sep 03, 2010 1:43 pm | All times are GMT
navigation Forum index » *nix » AIX
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts ntpdate and cron Susan FreeBSD 7 Thu Jul 13, 2006 6:47 am
No new posts Separate user timezones for cron, possible? Tim Jones AIX 4 Thu Jul 06, 2006 8:16 am
No new posts Cron : Step Values dawaves@gmail.com AIX 3 Mon Jul 03, 2006 10:56 pm
No new posts Cron Logs Mag Gam AIX 5 Mon Jul 03, 2006 12:29 pm
No new posts Cygwin problem with cron and networked drives ambroze@comcast.net networking 5 Wed Jun 28, 2006 2:54 pm

Copyright © 2004-2005 DeniX Solutions SRL
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum |  email marketing service
 
Sponsors: Iphone 3g | Floor Lamps | Debt Management | Breast Enlargement | Canon 500d
Privacy Policy
[ Time: 0.3134s ][ Queries: 21 (0.1759s) ][ GZIP on - Debug on ]