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

Thread: schedule script to run just after boot

  1. #1
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    schedule script to run just after boot

    I have a simple series of commands combined into 1 bash script so I can input several lines into the command prompt at once. How would I schedule this bash script to run automatically once my server has booted up?

    Cheers

    Ben

  2. #2
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: schedule script to run just after boot

    add it to the according runlevels --> http://www.debuntu.org/how-to-manage...th-update-rc.d

  3. #3
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    Re: schedule script to run just after boot

    Will take a look at that, thanks!

  4. #4
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    Re: schedule script to run just after boot

    Ok, so I copied the script to /etc/init.d/ and ran
    Code:
    update-rc.d myscript defaults
    and when I reboot it doesn't run.

    Any ideas?

  5. #5
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: schedule script to run just after boot

    it might requier a structure of an init script... if that does not help, you can still attach the script to your autostart - or is it required to run as root?

  6. #6
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    Re: schedule script to run just after boot

    This is the script:
    Code:
    #! /bin/bash
    # script to mount drives and share
    sudo mount /dev/sdb1 /media/disk
    sudo mount /dev/sdc1 /media/disk-1
    sudo mount /dev/sdd1 /media/disk-2
    sudo mount /home/user/shared
    sudo mount -a
    I'm sick of remounting the USB hard drives everytime I reboot so I jsut chucked the commands into 1 file with the intnetion of running 1 command instead of 5 every reboot.

    What do you think?

  7. #7
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: schedule script to run just after boot

    why don't you mount them in the /etc/fstab?

  8. #8
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    Re: schedule script to run just after boot

    That just gave me loads of problems and I couldn't get it to work. Also, the machine keeps switching the order of which one is sdb1, which is sdc1 and sdd1 etc, so mounting them manually is the only way I've been able to reliably mount them where I want them to be. Either running the script manually, or typing
    Code:
    sudo /etc/init.d/myscript start
    gets the drives to mount up, but is there any way to do this automatically?

  9. #9
    Join Date
    Jun 2006
    Location
    Switzerland
    Beans
    Hidden!
    Distro
    Kubuntu Jaunty Jackalope (testing)

    Re: schedule script to run just after boot

    if you have a script in the init.rd then you don't need a sudo, it will be run as root...

    but I think you'll need to put it into an init like script...

  10. #10
    Join Date
    Aug 2006
    Location
    North East England
    Beans
    576
    Distro
    Ubuntu

    Re: schedule script to run just after boot

    Right, will take a look at that!

    Cheers for your help!

Page 1 of 2 12 LastLast

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
  •