LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 10-12-2009, 04:56 PM   #1
mycoolwater
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Rep: Reputation: 0
Run a (service) command as a normal user during start up


I have found so many ways for root user to execute commands in so many possible path locations - but having difficulties on executing commands as normal user - during start up.

This is what i've got for /etc/rc.d/rc.local script:

Code:
su -l user && (/bin/sh svc_cmd.sh &)
But the command doesn't run at all... any better idea than above?

(this thread sort of a continued question of this: -thread-)
 
Old 10-12-2009, 05:14 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
Quote:
Originally Posted by mycoolwater View Post
Code:
su -l user && (/bin/sh svc_cmd.sh &)
But the command doesn't run at all... any better idea than above?
A few ideas. What's that -l option on the su command? According to the man page (on Slackware 13) there's no such option. Secondly, how will /bin/sh find svc_cmd.sh? It would have to be in the current directory for it to work and what is the current directory when the boot scripts are running? /? You could try giving the full path to svc_cmd.sh. Finally the su command will complete and if it completes successfully, after it has exited, the command line will run /bin/sh svc_cmd.sh & as root. Maybe this is closer to doing what you want to do:
Code:
(su - user -c /bin/sh <full path to>/svc_cmd.sh )&
Is there any particular reason for using /bin/sh rather than /bin/bash?

EDIT: as the command is going to be backgrounded and is a single command, the suggested command is pointlessly complex and can more simply be
Code:
su - user -c /bin/sh <full path to>/svc_cmd.sh &

Last edited by catkin; 10-12-2009 at 05:17 PM. Reason: Prettification
 
Old 10-13-2009, 05:59 PM   #3
mycoolwater
LQ Newbie
 
Registered: Apr 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a normal user run KDE? morphynoman Linux - Newbie 10 11-17-2008 08:09 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 04:38 PM
run command as normal user at boot time julot Slackware 2 01-28-2007 11:27 AM
how to run root command having normal user permission ravi.patil Linux - Newbie 7 05-21-2006 03:21 PM
Service won't start unless run as root user gauge73 Linux - General 3 05-07-2005 11:37 PM


All times are GMT -5. The time now is 11:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration