Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Scripts at boot and shutdown not running...

  1. #1
    Join Date
    Jul 2009
    Location
    Geneva, Switzerland
    Beans
    21
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question [SOLVED] Scripts at boot and shutdown not running...

    Hi
    I have a small but annoying problem... I have two scripts that I want to run automatically one at boot and one at shutdown.

    For the one at boot I tried to put it in rc.local or to create a file in /etc/init.d/ based on the others files in the folder but nothing worked... I need it to run system-wide and not once a specific user is logged in.

    For the script at shutdown I don't know how to do it but it can be user specific or system-wide I don't really care...

    I am running Ubuntu 10.10 64bits with kernel 2.6.35-24-generic

    If anyone has a solution, thanks.

    PS. I should add that when executed manually both scripts works perfectly well and I don't need those script to run continuously in the background, just run and quit.
    Last edited by OrnithO; January 22nd, 2011 at 12:40 AM. Reason: solved...

  2. #2
    Join Date
    Dec 2010
    Beans
    549

    Re: Scripts at boot and shutdown not running...

    The files in init.d are not run at boot. Some of them are linked from /etc/rcS.d (run for every boot) or rc2.d (run level two, normal X session). You'll quickly see the links. Add your script to init.d and a link to, perhaps rc2.d depending on when you want to run.

    Scripts at shutdown are run from the links in rc0.d, and for reboot from rc6.d.

    In most cases, adding some code in rc.local works, or calling another script. This avoids polluting the expected links. I'm not sure what happened to yours that it didn't run. This part of the boot isn't very visible because your X session will already be started and the splash is gone. Check that you have a link in rc2.d to run rc.local, usually S99rc.local to run near the end of the boot. Check your paths and syntax. Maybe start with something simple and visible.

  3. #3
    Join Date
    Jul 2009
    Location
    Geneva, Switzerland
    Beans
    21
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripts at boot and shutdown not running...

    Quote Originally Posted by lithopsian View Post
    In most cases, adding some code in rc.local works, or calling another script. This avoids polluting the expected links. I'm not sure what happened to yours that it didn't run. This part of the boot isn't very visible because your X session will already be started and the splash is gone. Check that you have a link in rc2.d to run rc.local, usually S99rc.local to run near the end of the boot. Check your paths and syntax. Maybe start with something simple and visible.
    Well I didn't have any link in rc2.d so I added it and checked the permissions and all but I didn't worked... My splash is deactivated but I didn't see any errors during the boot process. In fact I didn't see anything about rc.local...
    I also did put my script directly in rc2.d with S80 but didn't worked...

  4. #4
    Join Date
    Jul 2009
    Location
    Geneva, Switzerland
    Beans
    21
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripts at boot and shutdown not running...

    Quote Originally Posted by lithopsian View Post
    In most cases, adding some code in rc.local works, or calling another script. This avoids polluting the expected links. I'm not sure what happened to yours that it didn't run. This part of the boot isn't very visible because your X session will already be started and the splash is gone. Check that you have a link in rc2.d to run rc.local, usually S99rc.local to run near the end of the boot. Check your paths and syntax. Maybe start with something simple and visible.
    Well I didn't have any link in rc2.d so I added it and checked the permissions and all but I didn't worked... My splash is deactivated but I didn't see any errors during the boot process. In fact I didn't see anything about rc.local...
    I also did put my script directly in rc2.d with S80 but didn't worked...

    Whoops sorry for the double answer... Also I tried the method described on the wiki here but it didn't worked either...
    Last edited by OrnithO; January 17th, 2011 at 02:08 AM.

  5. #5
    Join Date
    Dec 2010
    Beans
    549

    Re: Scripts at boot and shutdown not running...

    I'm not sure what more I can add. If you have a script in /etc/init.d, correctly linked from the runlevel you are using, permissions set, execute but set, then it will get run. Otherwise your machine wouldn't boot at all.

    You can try putting something trivial earlier in the boot sequence. Maybe a log message and a sleep so you can see it pausing. Or not! Scripts often have trivial checks at the start which can cause them to exit if a certain file or executable isn't present, so make sure your rc.local isn't just exiting.

    Also check which runlevel you are actually booting into. Would be a shame to be putting links in rc2.d and booting at runlevel 3 Normally Ubuntu would boot to runlevel 2, but maybe something weird is happening. Levels 3, 4 and 5 are all more or less duplicates of 2 and you coud boot to any of them and not notice the difference.

  6. #6
    Join Date
    Jul 2009
    Location
    Geneva, Switzerland
    Beans
    21
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripts at boot and shutdown not running...

    Quote Originally Posted by lithopsian View Post
    Also check which runlevel you are actually booting into. Would be a shame to be putting links in rc2.d and booting at runlevel 3 Normally Ubuntu would boot to runlevel 2, but maybe something weird is happening. Levels 3, 4 and 5 are all more or less duplicates of 2 and you coud boot to any of them and not notice the difference.
    I'll try and do that but I'm not sure how to do it.. I can put a simple script with a log in each runlevel but is this the best solution?

  7. #7
    Join Date
    Dec 2010
    Beans
    549

    Re: Scripts at boot and shutdown not running...

    I should have said how. Just type runlevel in a terminal and it will tell you where you are. It will show you the previous and current runlevels. Typically the previous will be something like "n", just look at the number after it.

  8. #8
    Join Date
    Jul 2009
    Location
    Geneva, Switzerland
    Beans
    21
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Scripts at boot and shutdown not running...

    Ok I did it and the runlevel is 2, I don't understand... I think I am doing something wrong because even the simplest script in rc2.d does not run at boot...
    I was also looking for alternate solutions and I found here that you can do it with cron using the options @reboot but it doesn't work either...

  9. #9
    Join Date
    May 2010
    Location
    uk
    Beans
    9,324
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: Scripts at boot and shutdown not running...

    Hi

    Have a read up on update-rc.d

    http://www.debuntu.org/how-to-manage...th-update-rc.d

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  10. #10
    Join Date
    Dec 2010
    Beans
    549

    Re: Scripts at boot and shutdown not running...

    Post the contents of rc2.d (ls -l), including your link or the rc.local link. And post the contents of the rc.local script, and also ls -l /etc/init.d/rc.local.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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