Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have finished my script and I need to run it as a daemon, in background in order to keep it running while Iīm doing other tasks.
I explain u the situation. I have an script written in bash that manage telnet connections to monitorize a network. It works nice but I need to run it in background. I want to pass all the echos from the screen to a log file for debugging purposes. I have tried to use the usual structure to make daemon copying it from the dhcpd service for example, but it doesnīt work.
It seems to work but when it start, Isee the line running script..., but it stops there until the script is finished. Since is a loop script, this doesnīt happen never...
I also have tried to start the script finished with & and it works, but I donīt recover the console until it has finished.
Iīm connecting with the machine througt a telnet connection, so I donīt have multiple consoles to change it.
To have it go the the background automatically (without & on the commandline) you could do something like:
if [ "x$1" != "x--" ]; then
$0 -- 1> /dev/null 2> /dev/null &
inside the script. This will put start another instance of the script in the background if the first parameter is not -- and exit.
You will of course need to edit it a bit if you need to pass parameters to your script.
Distribution: Debian Etch (w/ dual-boot XP for gaming)
A minor note: While alienDog's solution works as intended, for any non-trivial program, you probably wouldn't want to lose the output. It would be much better to redirect the streams to a file instead of /dev/null, so that if there was an error, you could see what it was up to. Something like
if [ "x$1" != "x--" ]; then
$0 -- 1> ~/myscript.out.log 2> ~/myscript.err.log &
which will create two files in your home directory where the output will be logged. As it stands, this will empty the logs every time the script is run, which may be what you want - but if you'd rather keep all the generated output (and delete the contents manually when it gets too big) replace the single '>'s with double '>>'s, telling the script to append to the file rather than overwrite.