Hi all, is there a function (or variable) I can use in a custom init script that identifies the init script name? i.e. I'm porting some init scripts from gentoo, where the $SVCNAME variable identifies the init script name within the script itself...
d
/* Davide Cittaro
Cogentech - Consortium for Genomic Technologies via adamello, 16 20139 Milano Italy
tel.: +39(02)574303007 e-mail: davide.cittaro@ifom-ieo-campus.it */
On Fri, Dec 12, 2008 at 8:37 AM, Davide Cittaro davide.cittaro@ifom-ieo-campus.it wrote:
Hi all, is there a function (or variable) I can use in a custom init script that identifies the init script name? i.e. I'm porting some init scripts from gentoo, where the $SVCNAME variable identifies the init script name within the script itself... d
/* Davide Cittaro Cogentech - Consortium for Genomic Technologies via adamello, 16 20139 Milano Italy tel.: +39(02)574303007 e-mail: davide.cittaro@ifom-ieo-campus.it */
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Do you mean like $0? That gives you the current script name.
Jacques B.
On Dec 12, 2008, at 2:40 PM, Jacques B. wrote:
Do you mean like $0? That gives you the current script name.
:-) Fine, thanks, I thought that launching with /sbin/service somehow breaks positional variables...
d
/* Davide Cittaro
Cogentech - Consortium for Genomic Technologies via adamello, 16 20139 Milano Italy
tel.: +39(02)574303007 e-mail: davide.cittaro@ifom-ieo-campus.it */
Ok, another one: the process I would like to start is not a daemon itself. If I start it with "daemon" function it remains in foreground. Ok, I can play with '&' but is there a init function to start in background a process?
d /* Davide Cittaro
Cogentech - Consortium for Genomic Technologies via adamello, 16 20139 Milano Italy
tel.: +39(02)574303007 e-mail: davide.cittaro@ifom-ieo-campus.it */
Davide Cittaro wrote:
Ok, another one: the process I would like to start is not a daemon itself. If I start it with "daemon" function it remains in foreground. Ok, I can play with '&' but is there a init function to start in background a process?
You just hijacked your own thread. Better to start a new one.
The workaround I have used in this situation is a wrapper script that redirects stdin, stdout, and stderr and backgrounds, but that is playing with '&' indirectly. Please post if you find a more elegant solution.
Phil
Phil Schaffner wrote:
Davide Cittaro wrote:
Ok, another one: the process I would like to start is not a daemon itself. If I start it with "daemon" function it remains in foreground. Ok, I can play with '&' but is there a init function to start in background a process?
You just hijacked your own thread. Better to start a new one.
Nope, we're still in init-script territory :)
The workaround I have used in this situation is a wrapper script that redirects stdin, stdout, and stderr and backgrounds, but that is playing with '&' indirectly. Please post if you find a more elegant solution.
True. "daemon" itself cannot do that if the script doesn't detach from the terminal itself. But within the init script a "&" should be sufficient if no output is expected.
Ralph
Hi,
On Fri, Dec 12, 2008 at 09:13, Davide Cittaro davide.cittaro@ifom-ieo-campus.it wrote:
Ok, another one: the process I would like to start is not a daemon itself. If I start it with "daemon" function it remains in foreground. Ok, I can play with '&' but is there a init function to start in background a process?
Use "nohup" and redirect file descriptors to be safe.
nohup cmd... </dev/null >/dev/null 2>&1 &
Look up "man nohup" for (a few) more details.
HTH, Filipe