Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Starting a server through cron

 
   Soft32 Home -> Linux -> General Discussions RSS
Next:  [wifi] intel 4965AGN: change mode impossible  
Author Message
Nikos Chantziaras

External


Since: Nov 11, 2006
Posts: 263



(Msg. 1) Posted: Mon Nov 05, 2007 4:59 pm
Post subject: Starting a server through cron
Archived from groups: alt>os>linux>gentoo (more info?)

Hello group.

What's the best way to start a server program that runs in the
background at system boot from a normal (non-root) user account on our
Gentoo server?

Right now, my crontab looks like this:

MAILTO=""
@reboot foo -d
@reboot bar

Couple of notes: "foo" supports the -d option which means "run as
daemon" (ventrilo_srv for example has this). "bar" does not support
such option. If I would want to start it by hand from the shell, I
would probably do:

bar &

or:

screen bar

(and then detach).

What's the best way to start those with cron, and are there any
implications? Is it better to use "&" in the crontab?
Back to top
Login to vote
Arthur Hagen

External


Since: Oct 08, 2005
Posts: 23



(Msg. 2) Posted: Mon Nov 05, 2007 4:59 pm
Post subject: Re: Starting a server through cron [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Nikos Chantziaras <realnc RemoveThis @arcor.de> wrote:
> Hello group.
>
> What's the best way to start a server program that runs in the
> background at system boot from a normal (non-root) user account on our
> Gentoo server?
>
> Right now, my crontab looks like this:

cron is the wrong way to do it.
The most compatible way would be to set up a script in /etc/init.d/ that
starts the service, and changes the user to the one who should run it. Look
at the existing scripts in /etc/init.d/, and copy/modify one of them for
your own use. To start the command as a different user, either use

su - username -c "/path/to/command arguments"

or, if the service should *always* start as one particular user, simply suid
the server process to the user who should run it:

chown username /path/to/command
chmod u+s /path/to/command

After doing this, the app will always run as "username". (You might want to
combine the above with group changes too, with chgrp and chmod g+s.)

If adding a script in /etc/init.d/, don't forget to add it to the runlevel
where you want it started, e.g. "rc-update add yourscript default".

Alternatively, you can start the service from init directly, by editing
/etc/inittab, but then you can't set dependencies preventing the service
from starting "too early", i.e. before other services it might depend on
(like networking).

Or, if this is an internet service, you can have it start upon first access,
by editing /etc/inetd.conf (presuming the inetd super daemon is installed
and running). There's facilities in inetd.conf for starting a service as
the user of choice -- see the man page for details.

> What's the best way to start those with cron, and are there any
> implications?

You're hammering in nails with a wooden clog. I suggest using a hammer
instead.

Regards,
--
*Art
Back to top
Login to vote
Nikos Chantziaras

External


Since: Nov 11, 2006
Posts: 263



(Msg. 3) Posted: Mon Nov 05, 2007 6:44 pm
Post subject: Re: Starting a server through cron [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Arthur Hagen wrote:
> Nikos Chantziaras <realnc.DeleteThis@arcor.de> wrote:
>> Hello group.
>>
>> What's the best way to start a server program that runs in the
>> background at system boot from a normal (non-root) user account on our
>> Gentoo server?
>>
>> Right now, my crontab looks like this:
>
> cron is the wrong way to do it.
> The most compatible way would be to set up a script in /etc/init.d/ that
> starts the service, and changes the user to the one who should run it.

I wasn't too clear about it in the first post, sorry for that. The
problem is root access, which I don't have.


>> What's the best way to start those with cron, and are there any
>> implications?
>
> You're hammering in nails with a wooden clog. I suggest using a hammer
> instead.

I'm missing the hammer (root) Very Happy
Back to top
Login to vote
Display posts from previous:   
Related Topics:
X Font nightmare - The other day I rebooted after eighteen days, and every X font on my system went nuts. Now it's an adventure to see wha...

Auto starting a server at boot - I know that this is a basic question but, how do I automatically start an application at boot? I want to automatically...

rh9.0 new LCD monitor says "no signal" when starting x ser.. - Hola, Linux folk- Built a new machine over the weekend: ASUS A7N8X board PNY 128mb nvidia fx 5200 NEC Multisync LCD1765...

[gentoo-user] net.eth0 starting yet not starting - Weird problem. On my server net.eth0 isn't starting, yet it is. During boot it goes through the normal routine, it..

cron problems - I am having some trouble with an expect script I am running from cron. The script uses expect to spawn a telnet sessio...

Cron and streamer - I've got a security camera wired to a tv capture card in my webserver and I can run 'Streamer' which will save a..
       Soft32 Home -> Linux -> General Discussions All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]