- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- ksh: script to handle switch beetween users
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2012 08:17 AM
08-24-2012 08:17 AM
hello,
i want to collect some scripts to one script . i want start with "root" user, do some steps and switch to an "oracle" user.
in the oracle user i want to start another program with "nohup ./script 2>&1 > script.log &" .
- how can i check , if the script is finished and ok in the oracle user?
i also want to make the programm restart able.
what's the best way to handle this .
example :
#1.root
mkdir /oracle/mnt
echo "1. mkdir" >> /tmp/steps
chown oracle /tmp/steps
#2. oracle
su oracle <<-EOF
.
EOF
echo $?
echo "2. oracle" >> /tmp/steps
#3. oracle
# the special with nohup
su oracle <<-EOF
nohup ./script 2>&1 > script.log &
EOF
echo $?
echo "3. oracle" >> /tmp/steps
when an error will detect, the program stops and i have to check and solve the problem. then i will start the programm again and i will check with "awk", i one step was finished ?
regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2012 10:18 AM - edited 08-24-2012 10:19 AM
08-24-2012 10:18 AM - edited 08-24-2012 10:19 AM
Re: ksh: script to handle switch between users
I never recommend large monolithic scripts that do a lot of processing that could be broken down into smaller easier to restart scripts. However, they are sometimes required when you have complex processes that require a lot of global data to be passed from one process step to another. I also recommend making use of any job control system you may have, like control-m or autosys.
With that said, the methods I've seen use flag file(s) to record processing steps and their exit status. In the event of a failure that causes the process to halt, the core script can be restarted with either a restart flag, or designed to find and read the last unsuccessful flag and start processing again from that point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2012 10:55 AM
08-24-2012 10:55 AM
Re: ksh: script to handle switch between users
>in the oracle user I want to start another program with "nohup ./script 2>&1 > script.log &" .
If the outer script isn't doing anything else, you could wait, instead of putting it in the background. But you may not want to have it hangup on you.
>if the script is finished and ok in the oracle user?
>nohup ./script 2>&1 > script.log &
>EOF
>echo $?
The exit status here will just check to see if the su and nohup started but not the status of "script".
As Ken said, you need to record your status in a file. Either the contents or the existence of one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2012 05:33 AM
08-31-2012 05:33 AM
Re: ksh: script to handle switch between users
hello,
thank you for your answers.
it is a great idea to use a job control tool but for my issue it is a little overhead
why :
we have to do this steps ( or installation ) not every day or week, sometimes one time in a month .
>if the script is finished and ok in the oracle user?
>nohup ./script 2>&1 > script.log &
>EOF
>echo $?
this can we change from the background to the foreground for a better handling ?
so , i think , i have to do the jobs step by step and not i a whole script with user switches.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2012 07:21 PM
09-02-2012 07:21 PM
Re: ksh: script to handle switch between users
>this can we change from the background to the foreground for a better handling?
Yes. It's not like the script has anything else to do while waiting?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2012 04:12 AM
09-03-2012 04:12 AM
Re: ksh: script to handle switch between users
> Yes. It's not like the script has anything else to do while waiting?
no nothing, these step runs about 30 minutes or longer. so we start the script in the background because want to prevent interruption of network connection and so on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2012 10:27 AM