PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > Running a program at system startup
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

Running a program at system startup

Réponse
 
LinkBack Outils de la discussion
Vieux 20/08/2007, 21h10   #1
ArcticFox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Running a program at system startup

Here's the situation; I have a program that needs to run at system
startup, but there are a few issues with that. First, it must be run
with a certain directory as the working directory. Second it must be
run as the user 'Fox'

The information I've been able to find would end up with the program
running as root and not from the right directory. I'm used to Macs and
have no idea what I'm doing here, but I'm learning!

Thanks.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 21h20   #2
ArcticFox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup


On Aug 20, 2007, at 2:15 PM, Neil Watson wrote:

> The scripts in /etc/init.d are working examples of what you are trying
> to do.
>

Yea I was directed there before, but those are what I was talking about
where they don't do the two things I need them to do.
> --
> Neil Watson | Debian Linux
> System Administrator | Uptime 2 days
> http://watson-wilson.ca
>



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 21h20   #3
Neil Watson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

The scripts in /etc/init.d are working examples of what you are trying to do.

--
Neil Watson | Debian Linux
System Administrator | Uptime 2 days
http://watson-wilson.ca


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 21h30   #4
Jeff D
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On Mon, 20 Aug 2007, ArcticFox wrote:

>
> On Aug 20, 2007, at 2:15 PM, Neil Watson wrote:
>
>> The scripts in /etc/init.d are working examples of what you are trying to
>> do.
>>

> Yea I was directed there before, but those are what I was talking about where
> they don't do the two things I need them to do.


what about something like this:

#!/bin/sh
cd /to/your/dir
/bin/su -c "./yourapp" user-to-run-as


-+-
8 out of 10 Owners who Expressed a Preference said Their Cats Preferred Techno.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 21h30   #5
srgqwerty
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

Create a script in /etc/init.d and make a symbolic link to it in the rc
runlevel directory that corresponds to your runlevel (or whatever runlevel
you want the script to run).

For example, the /etc/init.d/foo.sh may be:
#!/bin/bash
cd /foo
/foo/make_something.sh

If you want this script to run in runlevel 2, then you can:
ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo

In the other hand, at any moment you can now the runlevel in what you are just
typing:
who -r

Have a look at /etc/init.d scripts, they are self explanatory.
Also, have a look at "man init"

Regards

On Monday 20 August 2007 21:00, ArcticFox wrote:
> Here's the situation; I have a program that needs to run at system
> startup, but there are a few issues with that. First, it must be run
> with a certain directory as the working directory. Second it must be
> run as the user 'Fox'
>
> The information I've been able to find would end up with the program
> running as root and not from the right directory. I'm used to Macs and
> have no idea what I'm doing here, but I'm learning!
>
> Thanks.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 21h30   #6
Neil Watson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On Mon, Aug 20, 2007 at 02:17:24PM -0500, ArcticFox wrote:
>On Aug 20, 2007, at 2:15 PM, Neil Watson wrote:
>
>>The scripts in /etc/init.d are working examples of what you are trying
>>to do.
>>

>Yea I was directed there before, but those are what I was talking about
>where they don't do the two things I need them to do.


/etc/init.d/skeleton
man start-stop-daemon

--
Neil Watson | Debian Linux
System Administrator | Uptime 2 days
http://watson-wilson.ca


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 20/08/2007, 22h30   #7
Mihamina (R12y) Rakotomandimby
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On Mon, 2007-08-20 at 21:20 +0200, srgqwerty wrote:
> Create a script in /etc/init.d and make a symbolic link to it in the
> rc runlevel directory that corresponds to your runlevel


invoke-rc.d is the tool to do that.
Anyway, you did not indicate enough how to run the things as a
particular user.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 21/08/2007, 00h40   #8
Nate Bargmann
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

* srgqwerty <srgqwerty@gmail.com> [2007 Aug 20 14:25 -0500]:
> Create a script in /etc/init.d and make a symbolic link to it in the rc
> runlevel directory that corresponds to your runlevel (or whatever runlevel
> you want the script to run).
>
> For example, the /etc/init.d/foo.sh may be:
> #!/bin/bash
> cd /foo
> /foo/make_something.sh
>
> If you want this script to run in runlevel 2, then you can:
> ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo


I like to create my local init scripts in /usr/local/etc/init.d and
symlink from there. It prevents, however unlikely, a conflict with
the Debian scripts. It also makes it quite easy to find that local
script that was created many moons ago.

- Nate >>

--
Wireless | Amateur Radio Station N0NB | Successfully Microsoft
Amateur radio exams; ham radio; Linux info @ | free since January 1998.
http://www.qsl.net/n0nb/ | "Debian, the choice of
My Kawasaki KZ-650 SR @ | a GNU generation!"
http://www.networksplus.net/n0nb/ | http://www.debian.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 21/08/2007, 14h30   #9
Ralph Katz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On 08/20/2007 03:00 PM, ArcticFox wrote:
> Here's the situation; I have a program that needs to run at system
> startup, but there are a few issues with that. First, it must be run
> with a certain directory as the working directory. Second it must be run
> as the user 'Fox'


I'm no expert, but how about using cron and crontab for user fox? Use
"@reboot' for the start time.

man cron
man crontab

Good luck!

Ralph


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 21/08/2007, 16h20   #10
Douglas A. Tutty
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On Tue, Aug 21, 2007 at 08:20:04AM -0400, Ralph Katz wrote:
> On 08/20/2007 03:00 PM, ArcticFox wrote:
> > Here's the situation; I have a program that needs to run at system
> > startup, but there are a few issues with that. First, it must be run
> > with a certain directory as the working directory. Second it must be run
> > as the user 'Fox'


man start-stop-daemon

specificically:

-c Change to this username/uid before starting the process

-d Chdir to path before starting the process.


Doug.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 22/08/2007, 02h10   #11
ArcticFox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup


On Aug 20, 2007, at 2:20 PM, srgqwerty wrote:

> Create a script in /etc/init.d and make a symbolic link to it in the rc
> runlevel directory that corresponds to your runlevel (or whatever
> runlevel
> you want the script to run).


So just chuck it in anywhere? Does it matter who owns the file? Should
it be the user? root?
>
> For example, the /etc/init.d/foo.sh may be:
> #!/bin/bash
> cd /foo
> /foo/make_something.sh
>
> If you want this script to run in runlevel 2, then you can:
> ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo


So I'd make the file, put it somewhere in /etc/init.d then symlink it
to /etc/rc2.d ? Seems kinda... random to me.
>
> In the other hand, at any moment you can now the runlevel in what you
> are just
> typing:
> who -r
>
> Have a look at /etc/init.d scripts, they are self explanatory.


There's no directory in /etc/init.d called scripts. I know nothing
about shell scripting and many of you seem to assume that I know what
I'm doing here. I'm a Mac guy, command lines still scare me.

> Also, have a look at "man init"
>
> Regards
>
> On Monday 20 August 2007 21:00, ArcticFox wrote:
>> Here's the situation; I have a program that needs to run at system
>> startup, but there are a few issues with that. First, it must be run
>> with a certain directory as the working directory. Second it must be
>> run as the user 'Fox'
>>
>> The information I've been able to find would end up with the program
>> running as root and not from the right directory. I'm used to Macs and
>> have no idea what I'm doing here, but I'm learning!
>>
>> Thanks.



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 22/08/2007, 03h20   #12
Jeff D
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Running a program at system startup

On Tue, 21 Aug 2007, ArcticFox wrote:

>
> On Aug 20, 2007, at 2:20 PM, srgqwerty wrote:
>
>> Create a script in /etc/init.d and make a symbolic link to it in the rc
>> runlevel directory that corresponds to your runlevel (or whatever runlevel
>> you want the script to run).

>
> So just chuck it in anywhere? Does it matter who owns the file? Should it be
> the user? root?
>>
>> For example, the /etc/init.d/foo.sh may be:
>> #!/bin/bash
>> cd /foo
>> /foo/make_something.sh
>>
>> If you want this script to run in runlevel 2, then you can:
>> ln -s /etc/init.d/foo.sh /etc/rc2.d/S99foo

>
> So I'd make the file, put it somewhere in /etc/init.d then symlink it to
> /etc/rc2.d ? Seems kinda... random to me.
>>
>> In the other hand, at any moment you can now the runlevel in what you are
>> just
>> typing:
>> who -r
>>
>> Have a look at /etc/init.d scripts, they are self explanatory.

>
> There's no directory in /etc/init.d called scripts. I know nothing about
> shell scripting and many of you seem to assume that I know what I'm doing
> here. I'm a Mac guy, command lines still scare me.
>
>> Also, have a look at "man init"
>>
>> Regards



/etc/init.d/ is where all of the startup scripts should live. /etc/rc2.d
for example, holds all the scripts that get started up in run level 2,
which is the defult run level for debian, so it may seem random, but
really its not. It's just easier to have the scripts in /etc/init.d/ and
link them to all the differnt run levels if you need them. The S99 , says
start and the init process executes each script in a numerical order, if
you look in /etc/rc2.d you will see a which order things get started.
Usually for user added stuff 99 is good.

So first thing you need to do, it make the script so that it runs the way
you want. You also have to remember that scripts get ran as root at start
up too. But you need to have your command ran as fox right? so:

su -c "command" fox

that will run the command you want as fox, through su.

for example:
#!/bin/sh
PATH=/bin:/usr/bin
cd /usr/local/myapp/
su -c "./myappp " fox

that, if ran throught the init process would result the script cd'ing into
the directory /usr/local/myapp/ and running myapp as fox..

once you have your script working the way you want it to, place it in
/etc/init.d then link it as above.

Also, take a look at /etc/rc2.d/README

hth
Jeff


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 04h39.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18424 seconds with 20 queries