Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Start/stop crontab intelligent script check solaris version

Status
Not open for further replies.

blueeyedme

Technical User
Nov 27, 2002
39
0
0
NL
Hello,

I have a script on solaris 8 that restarts the cron every night.
This is by just doing

/etc/init.d/cron stop
/etc/init.d/cron start

Now i also need to make this script more intelligent to let it check the OS version of solaris.
In case of solaris 10 it needs to do

scvadm cron restart

How can i achieve this in a shell script?

Thanks,
 
You could perhaps grep for '5.8' from a uname -a in your script. This would indicate a Solaris 8 box.

As a matter of interest, why are you restarting cron in this way?

I want to be good, is that not enough?
 
To reset some logging output which is being sent in a nightly batch.
 
Would the grep option I mentioned work for you? Something like:

uname -a | grep '5.8'
if [ $? -eq 0 ]
then
<Solaris 8 version of stop/start>
else
<Solaris 10 version of stop/start>
fi

might do the trick, but it's not tested as I'm not at work today. It would also carry out the Solaris 10 procedure if, say, you hade a Solaris 9 box, but that would be fairly simple to cope with.

It's possible you may have to escape the '5.8' like '5\.8'.


I want to be good, is that not enough?
 
I made it like this now and seems to work :

#!/bin/sh

#Check solaris version and trim results
solver=`uname -r|cut -d. -f 2`

if [ ${solver} -le 10 ]; then

#Solaris version lower then 10 do this
./etc/init.d/cron restart

else

#Solaris version 10 do this
svcadm restart cron

fi
 
Shouldn't this:
if [ ${solver} -le 10 ]; then

be replaced with this ?
if [ ${solver} -lt 10 ]; then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
@PHV
I don't know, whats the difference exactly?
Not at work at the moment so can't check.

Thanks :)
 
le - less than or equal to.

lt - less than

Good catch PHV (as usual!).

I want to be good, is that not enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top