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

Creating a shell script to be executed by cron....

Status
Not open for further replies.

hd7106

Programmer
Nov 27, 2002
21
US
I have situation where I need to reboot Solaris system using the standard /etc/shutdown script. However, prior to reboot I would like to terminate some tasks and applications using the binaries provided by the application provider. These binaries will only run as a normal user logged in with a specific environment settings and will not run as root user; unledd you use "su -" to maintian the environemnt.

Since I need to execute these binaries within cron, and recognizing the fact, that /etc/shutdown can only be executed by root; I need to derive a script to maintain the user's environemnt as well be able to execute shutdown. Any thoughst or ideas will be much appreciated.

Hasmukh Daji
 
You could have the script source the user's environment files before running the binaries or possibly run the su command as a user like this:

su - USERNAME -c "command [args]"


-jim
 
As J1mbo says, source the user environment files within the script to run the binaries - in particular, make sure the $PATH is set appropriately by defining it specifically. HTH.
 
Thanks for the help.

I did test the script within the cron schedule and works great. Although, I call this shell script from root user, which makes it easier to invoke normal user's environment using &quot;su - <user> -c &quot;.....&quot; syntax.

Much appreciate it,
Hasmukh Daji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top