On Tuesday 04 September 2007 11:02, LJ Mace wrote:
>I'm trying to finish a script that will bring
>down/backup/zip/restart our database and schedule it
>using crontab.
>If I su to root and start the script it works fine.
>I've got everthing working except the down part of
>DB2.
>Everytime I issue the command I get permission denied.
>I was getting it on the force but I set the profile
>and that part works. I just can't seem to get db2stop
>command to work.
>Here is the command I have in the script:
>/opt/IBM/db2/V8.1/adm/db2stop
>What am I missing?
>What's the difference in su and placing something in
>roots crontab??

The environment can be very different.  When you su without any options, you
are keeping the environment of the original user (for the most part).  If
you "su -", you are setting up the environment as if you had logged in as
root (it runs /root/.profile or /root/.bash_profile for you).  But when cron
runs a root crontab, it only sets up a few environment variables (SHELL,
LOGNAME and HOME).  See crontab(5) for details.

You could source $HOME/.bash_profile if you want, but I'm wondering why you're
doing the db2stop as root.  Shouldn't you do that as your DB2 instance user?
I would put this into my crontab script:

su - db2inst1 -c /opt/IBM/db2/V8.1/adm/db2stop

That will run the db2stop command in a shell whose environment has been set up
as if the db2inst1 user had logged in, so it is pretty likely to have
everything set up for db2stop to work properly.
        - MacK.
-----
Edmund R. MacKenty
Software Architect
Rocket Software, Inc.
Newton, MA USA

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to