Run script with different user at the startup .. | Unix Linux Forums | AIX

  Go Back    


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Run script with different user at the startup ..

AIX


Tags
aix, unix

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 04-16-2010
Mr.AIX Mr.AIX is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 22 December 2011, 3:50 PM EST
Posts: 90
Thanks: 1
Thanked 1 Time in 1 Post
Run script with different user at the startup ..

Run script with different user at the startup ..

I have created this user appuser

And I have a script should to be up thru the startup by this user appuser

I have defined the path of the script /user/appstart.sh in /etc/rc

But at the startup starting will be by root , I’d like to keep the starting of that script to be by appuser not root .


Pls advice in this..
Sponsored Links
    #2  
Old 04-16-2010
thegeek thegeek is offline
Read Only
 
Join Date: Apr 2009
Last Activity: 30 July 2012, 5:38 AM EDT
Location: /usr/bin/vim
Posts: 946
Thanks: 13
Thanked 38 Times in 36 Posts
normally in debian, i used to do like,
Code:
 su USER -c 'command &'

Hope it helps.
Sponsored Links
    #3  
Old 04-16-2010
ross.mather ross.mather is offline
Registered User
 
Join Date: Aug 2008
Last Activity: 29 October 2014, 5:12 PM EDT
Location: Nomadic in the UK
Posts: 136
Thanks: 6
Thanked 9 Times in 9 Posts
The script in /etc/rc should contain the line that the geek suggested and then your other script can be anywhere you like.
    #4  
Old 04-18-2010
Mr.AIX Mr.AIX is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 22 December 2011, 3:50 PM EST
Posts: 90
Thanks: 1
Thanked 1 Time in 1 Post

Code:
 
su USER -c 'command &'


Many thanks this command very helpful ...
Sponsored Links
    #5  
Old 09-04-2010
Mr.AIX Mr.AIX is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 22 December 2011, 3:50 PM EST
Posts: 90
Thanks: 1
Thanked 1 Time in 1 Post
Guy's ,

that command is working fine but is there another way to do the same thing to run the command by root and to be executed by appuser user
Sponsored Links
    #6  
Old 09-08-2010
john1212 john1212 is offline
Registered User
 
Join Date: Mar 2010
Last Activity: 25 May 2012, 11:08 AM EDT
Posts: 141
Thanks: 0
Thanked 19 Times in 19 Posts
I think you need:

Code:
su -l appuser -c command

su with -l (or -) means:
Provide an environment similar to what the user would expect had the user logged in directly.
Sponsored Links
    #7  
Old 09-08-2010
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 21 August 2014, 4:30 PM EDT
Posts: 1,136
Thanks: 2
Thanked 88 Times in 85 Posts
Quote:
Originally Posted by john1212 View Post
I think you need:

Code:
su -l appuser -c command

su with -l (or -) means:
Provide an environment similar to what the user would expect had the user logged in directly.
su -l does not work on AIX. su - should be used.


from Run level script execution
Quote:
I would not edit /etc/rc directly because your updates will eventualy get overwritten by an upgrade. Create a rc script the proper way. It will be called by the /etc/rc script. Another alternative is to add it to /etc/inittab.

Run level script execution

Run level scripts allow users to start and stop selected applications while changing the run level.
Put run level scripts in the subdirectory of /etc/rc.d that is specific to the run level:

* /etc/rc.d/rc2.d
* /etc/rc.d/rc3.d
* /etc/rc.d/rc4.d
* /etc/rc.d/rc5.d
* /etc/rc.d/rc6.d
* /etc/rc.d/rc7.d
* /etc/rc.d/rc8.d
* /etc/rc.d/rc9.d

The /etc/rc.d/rc will run the scripts it finds in the specified directory when the run level changes - first running the stop application scripts then running the start application scripts.
Note: Scripts beginning with K are stop scripts, while scripts beginning with S are start scripts.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need to run script at startup. pinga123 Shell Programming and Scripting 3 02-08-2010 04:49 AM
run script at startup pchangba1 AIX 1 11-06-2008 10:51 AM
Startup script texaspanama Shell Programming and Scripting 2 06-29-2006 04:08 PM
ksh in rc3.d startup script JayNick Shell Programming and Scripting 1 05-19-2006 12:28 PM
Startup script DSL c19h28O2 Shell Programming and Scripting 0 04-11-2006 05:54 AM



All times are GMT -4. The time now is 07:06 PM.