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

Thread: How do I run a command on start up?

  1. #1
    Join Date
    Jul 2005
    Location
    DC / Richmond VA area
    Beans
    383
    Distro
    Ubuntu 10.04 Lucid Lynx

    How do I run a command on start up?

    Ever since I upgraded to 9.04 my NAT drive does not mount on boot, and if I don't remember to mount the drive before opening Rhythmbox it dumps the music dB and I have to wait 5 minutes for it rescan my music drive after I mount it again.

    Fstab is fine as sudo mount -a mounts everything normally. I don't know why it's not mounting but I'm fine with a workaround if I can find one.

    How can I automate a sudo - mount -a command on every startup?

  2. #2
    Join Date
    Jul 2006
    Location
    Here
    Beans
    10,273

    Re: How do I run a command on start up?

    post your fstab.

    for now you can put " mount -a &" in /etc/rc.local it runs as root already so no need sudo.

  3. #3
    Join Date
    Jul 2005
    Location
    DC / Richmond VA area
    Beans
    383
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How do I run a command on start up?

    My fstab...(the NAT drive has a static IP of 192.168.11.7) None of the NAT drive mounts are mounting at boot.

    Code:
    # /etc/fstab: static file system information.
    #
    #  -- This file has been automaticly generated by ntfs-config --
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    
    proc /proc proc defaults 0 0
    # Entry for /dev/sda5 :
    UUID=54bed292-dd3b-451d-b414-c4e8a70dc7b5 / ext3 defaults,errors=remount-ro,relatime 0 1
    # Entry for /dev/sda6 :
    UUID=579b6ae8-6bc8-495b-8006-6b896c4c8abb none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
    /dev/sda7 /home ext3 nodev,nosuid,relatime 0 2
    192.168.11.7:/shares/SimplePool/Music /mnt/music nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/Photos /mnt/photos nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/backups /mnt/backups nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/NetFolder /mnt/NetFolder nfs rsize=8192,wsize=8192,timeo=14,intr 0 0

  4. #4
    Join Date
    Jul 2006
    Location
    Here
    Beans
    10,273

    Re: How do I run a command on start up?

    what i think is happening is the mount is run before your network is up.
    check your /var/log/messages for errors.

    did the "mount -a &" work in /etc/rc.local ?

  5. #5
    Join Date
    Nov 2005
    Location
    Pacific Northwest
    Beans
    268

    Re: How do I run a command on start up?

    what is the perferred way to add a mount point, other than during installation?
    AMD 64 3000+, 2G RAM, ASUS K8N , XFX GS7800, Linux Mint 9 , WinXP(dual boot/seperate HD)

    Stalker's Law: As an online discussion grows longer, the probability of a comparison involving how much the United States sucks approaches one.

  6. #6
    Join Date
    Mar 2008
    Location
    Connecticut
    Beans
    940
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How do I run a command on start up?

    Quote Originally Posted by chrisod View Post
    My fstab...(the NAT drive has a static IP of 192.168.11.7) None of the NAT drive mounts are mounting at boot.

    Code:
    # /etc/fstab: static file system information.
    #
    #  -- This file has been automaticly generated by ntfs-config --
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    
    proc /proc proc defaults 0 0
    # Entry for /dev/sda5 :
    UUID=54bed292-dd3b-451d-b414-c4e8a70dc7b5 / ext3 defaults,errors=remount-ro,relatime 0 1
    # Entry for /dev/sda6 :
    UUID=579b6ae8-6bc8-495b-8006-6b896c4c8abb none swap sw 0 0
    /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
    /dev/sda7 /home ext3 nodev,nosuid,relatime 0 2
    192.168.11.7:/shares/SimplePool/Music /mnt/music nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/Photos /mnt/photos nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/backups /mnt/backups nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    192.168.11.7:/shares/SimplePool/NetFolder /mnt/NetFolder nfs rsize=8192,wsize=8192,timeo=14,intr 0 0
    Shouldn't that be //192.168.11.7:/blah/blah....
    Ubuntu 10.04-Server: HP Pavilion: AMD Athlon 3200; 2gb RAM; GeForce4 MX - nForce; 160gb HDD; 1TB eSATA External HDD | Ubuntu 10.04: Dell D600; Intel Pentium M 1600 MHz; 2gb RAM; ATI Radeon 9000 (RV250); 60gb HD | Ubuntu User #24614

  7. #7
    Join Date
    Jul 2005
    Location
    DC / Richmond VA area
    Beans
    383
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How do I run a command on start up?

    did the "mount -a &" work in /etc/rc.local ?
    Nope - NAT drive did not mount on a reboot. Upon investigation it seems as though rc.local is never running due to a DNS error during boot when it can't find 192.168.11.7. So the problem does seem to be that it is trying to mount the drive before the network is up.

    My first thought about a fix was to just comment out the mount commands from fstab and mount in the rc.local script. That isn't working because I'm still getting a mount.nfs DNS resolution error on 192.168.11.7 on boot, so the rc.local script never runs. I can start the rc.local script manually so I know the script is good, if I can just get it to run. I don't know why my laptop is trying to mount 192.168.11.7 when all 4 mount commands are commented out of fstab. Where else would be picking up the NAT drive from?

    Any ideas?

  8. #8
    Join Date
    Jul 2005
    Location
    DC / Richmond VA area
    Beans
    383
    Distro
    Ubuntu 10.04 Lucid Lynx

    [solved]Re: How do I run a command on start up?

    OK, I understand what is going on...and I have a workaround. With Intepid and Jaunty, the network connection is not established until you log in. It has something to do with how Network Manager works. If you have a desktop or laptop that isn't particularly mobile, you can simply configure the network the old fashioned way in /etc/network/interfaces and you should be ok. I'm mobile, so that would be a PITA for me. I took the mount commands out of fstab, added them to rc.local, and put a sleep 180 at the top of rc.local to give the network time to come up after login. It works fine as long as I log in immediately, which I usually do. It's not a perfect solution but good enough for now.

  9. #9
    Join Date
    Jul 2006
    Location
    Here
    Beans
    10,273

    Re: [solved]Re: How do I run a command on start up?

    Quote Originally Posted by chrisod View Post
    OK, I understand what is going on...and I have a workaround. With Intepid and Jaunty, the network connection is not established until you log in. It has something to do with how Network Manager works. If you have a desktop or laptop that isn't particularly mobile, you can simply configure the network the old fashioned way in /etc/network/interfaces and you should be ok. I'm mobile, so that would be a PITA for me. I took the mount commands out of fstab, added them to rc.local, and put a sleep 180 at the top of rc.local to give the network time to come up after login. It works fine as long as I log in immediately, which I usually do. It's not a perfect solution but good enough for now.
    i would just script it than, remove everything from rc.local and deal with it on the user end.

    example:
    make sure you have pmount> sudo apt-get install pmount
    pmount mounts as the user so you shouldn't have permission problems

    mkdir ~/bin
    gedit ~/bin/connect

    Code:
    #!/bin/sh
    if [ -d "192.168.11.7:/shares" ] ; then
     pmount 192.168.11.7:/shares/SimplePool/Music
     pmount 192.168.11.7:/shares/SimplePool/Photos
     pmount 192.168.11.7:/shares/SimplePool/backups
     pmount 192.168.11.7:/shares/SimplePool/NetFolder
    else
     exit 0
    fi
    chmod +x ~/bin/connect

    (might need to add sleep to that if the connections slow connecting)

    then just add> connect to your session startup

    not sure if that's correct but i would go that route. work it out on the user end. just my thought.

  10. #10
    Join Date
    Jul 2005
    Location
    DC / Richmond VA area
    Beans
    383
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: How do I run a command on start up?

    Thanks. I'll try the script and report back if it works.

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
  •