Find the answer to your Linux question:
Results 1 to 6 of 6
I don't know if this the right section but in anycase the question is: - I made a script containing a never ending loop doing : sleep X then command ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2009
    Posts
    7

    start script automatically


    I don't know if this the right section but in anycase the question is:
    - I made a script containing a never ending loop doing : sleep X then command Y', the problem is:
    can I start this script from init.d without the effect of blocking forever the boot process ?
    Or is better to insert a specific entry in inittab ?
    Or use cron instead?
    Thanks n advance

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,345
    It does sound like a job for cron.
    You must always face the curtain with a bow.

  3. #3
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    145

    Post

    Anyway you do it, if you do not want system to hang up, you should run this script in background

    Code:
    myscript.sh &

  4. #4
    Just Joined!
    Join Date
    Dec 2009
    Posts
    7
    Thanks for all responses, likely I will use cron, but , Schmidt, what is to be done to run a script in backgount by means of init.d and/or inittab?
    I'm almost green in this sector and I didn't find any example in the internet

  5. #5
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    145

    Post

    Quote Originally Posted by karpanasca View Post
    Thanks for all responses, likely I will use cron, but , Schmidt, what is to be done to run a script in backgount by means of init.d and/or inittab?
    I'm almost green in this sector and I didn't find any example in the internet
    Generally shell launches program and wait for its termination (it's called 'foreground process'). It means that when you launch a process, the terminal would sleep until process ends. But if you want to start a process and continue to interact with shell, you launch it in background, using '&' after it - it means that shell would not wait and immediatly returns. So, if you invoke a text editor in terminal ('vi' or 'emacs'), it will be opened and your terminal will be occupied by it until you close it. But if you write

    Code:
    $ vi &
    you would not see your editor appeared, because it will start in background. You should see something like

    Code:
    $ vi &
    [1] 1424
    $
    It means that shell waiting for your orders again ignoring VI.
    Now you could see it, if put it to foreground, using 'fg' command.

    '/etc/nittab' and '/etc/init.d/' are related to system 'runlevels'. It means that system can be launched with different amount of running services, for example runlevel 1 - it's a single user mode without networking, runlevel 3 is often used on servers - this is multiuser mode with full network support, but without GUI, runlevel 5 - level where often KDE or Gnome are appeared. If you only need to make your program depending on some system state, then you should use runlevels. If you are not developing a system component you do not need using runlevels, I suppose Cron would do the job

  6. #6
    Just Joined!
    Join Date
    Dec 2009
    Posts
    7
    Thanks again, Schmidt
    I'll surely go for cron, my curiosity was only because from your first answer I understood that is in someway possible to append an & to a script which is launched by a Sxx simlink in a rcX.d dir (that is, the init.d method) in order to spawn (or detach or what else) a process dedicated to the suspensive script. Evidently this is not possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •