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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"su" issues

Status
Not open for further replies.

unixkid

IS-IT--Management
May 22, 2001
105
US
I'm trying to "su" as root in a cron with the following

su - newuser -c "/opt/script"

the script will not run but will run fine it fromt eh command line
 
Hi,
This may be because the script is owned by root and is not executable by the userid that u want it to run from.Just change the permissions for it and try executing again.
I hope this helps....
 
nope the script is owned by the correct user. It errors as if it cant find all of the su-ed users enviorment files & settings. Even though I'm sourcing those in the script at the begining.
 
Hi,
ok....then the script is probably not able to export the settings that u have declared in that.can u show the script?
 
############################################################
# --- starts EMSEUWEB WEB and dbase #
########################################################
su - oracle -c "/u01/app/oracle/admin/scripts/start_EMSEUWEB_db"
su - oracle -c "/u01/app/oracle/admin/scripts/start_WEB_db"
####################################################
/opt/IBMHTTPD/bin/apachectl start
#############################################################################
#---- starts IBM WebSphere Server
nohup /opt/WebSphere/AppServer/bin/startupServer.sh &
##############################################################################
# --- start Application
su - ems -c "/u02/app/EMSEUWEB/TradeSphere72/scripts/ts_start.sh"
############################################################# ---- Start EMS Application
############################################################su - ems -c "/u02/app/EMSEUWEB/scripts/startenv.ksh"
su - ems -c "/u02/app/EMSEUWEB/scripts/starte
 
Hi,
u'r script seems to be fine....I think u'r problem is occurring when the application starts.One more thing: does u'r script ts_start.sh depend upon Websphere server.If it does ,then the prob cud be due to that as Websphere app may not have started by that time u'r script executes.
Secondly, u can also try this:-give sh before the command eg('sh /u02/app/EMSEUWEB/TradeSphere72/scripts/ts_start.sh'.
See if this helps......
 
what is the sh doing at the front of the script. I was thinking maybe if I put $HOME/.profile at the head of the script it might source in the ENV
 
Well u can source .profile also, in the beginning of the script and sh is the shell-command interpreter which executes u'r *.sh scripts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top