LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-09-2007, 11:51 PM   #1
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Rep: Reputation: 30
Run init script as daemon


I just added a small script to my init scripts, it basically continuously reads a pipe. If I run this script from the command line without & if freezes my screen and I can't stop it. Now I wonder if the same is going to happen when I reboot. Is there any way to tell the script to run as a daemon directly? TIA
 
Old 02-10-2007, 07:35 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
In whatever init file calls your init script, try putting a & after the call to your script.

For example, if your call to your init script says:

Code:
/etc/rc.d/localscripts/mylocalscript
then it should now say:

Code:
/etc/rc.d/localscripts/mylocalscript &
Hope this helps.

Last edited by wjevans_7d1@yahoo.co; 02-10-2007 at 07:41 AM.
 
Old 02-10-2007, 06:01 PM   #3
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
Thanks for your answer, I knew that one, but I meant something inside the script so I didn't have to call it with the & at the end.
 
Old 02-11-2007, 06:14 AM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
If you're programming entirely with bash scripts, and you want to start something that continues after the boot process is complete, I don't think you can avoid "&".
 
Old 02-11-2007, 06:40 AM   #5
alienDog
Member
 
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
It's possible to avoid the &:

#!/bin/bash
if [ "x$1" != "xdaemon" ]; then
$0 daemon &
exit 0
fi

... the rest of your script goes here
 
Old 02-12-2007, 01:29 AM   #6
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
Thanks for all the answers. That's what I was looking for alienDog.
 
  


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
Run my bash script as a daemon. jaimese Linux - Newbie 12 02-10-2011 03:28 PM
Can't get script to run from symlink in etc/init.d goggyturk Debian 5 12-05-2006 12:34 PM
How to run startup script/daemon as a user other than root? Akhran Debian 2 02-04-2006 01:20 AM
How to run a perl script as a daemon ? paonethestar Programming 17 11-06-2003 08:53 PM
init script won't run at log-off dimangi Linux - Newbie 1 10-29-2003 02:19 AM


All times are GMT -5. The time now is 04:20 PM.

Main Menu
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