runnings commands on ubuntu start up

Discussion in 'all things UNIX' started by aigle, Sep 8, 2015.

  1. aigle

    aigle Registered Member

    Joined:
    Dec 14, 2005
    Posts:
    11,047
    Location:
    Saudi Arabia/ Pakistan
    How can I run these two commands on start up in ubuntu.
    I tried to put them in /etc/rc.local but that doesn't work or may be they run even before my wifi network is up and conneceted?

    Thanks for any help.
     

    Attached Files:

    • 35.jpg
      35.jpg
      File size:
      58 KB
      Views:
      17
  2. mirimir

    mirimir Registered Member

    Joined:
    Oct 1, 2011
    Posts:
    6,029
    There's a startup service. I don't have any Ubuntu around now.
     
  3. Trespasser

    Trespasser Registered Member

    Joined:
    Mar 1, 2005
    Posts:
    1,194
    Location:
    Virginia - Appalachian Mtns
    Is grive a bash script?
    Bob
     
  4. Trespasser

    Trespasser Registered Member

    Joined:
    Mar 1, 2005
    Posts:
    1,194
    Location:
    Virginia - Appalachian Mtns
    So it is a bash script.

    [Desktop Entry]
    Type=Application
    Exec=bash -c "~/grive"
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[en_US]=Grive
    X-GNOME-Autostart-Delay=0

    Copy this to gedit. Name it grive.desktop. Place it in the ~/.config/autostart folder. And reboot. The X-GNOME-Autostart-Delay entry is for how long you want your system to wait, in seconds, before the script is to execute. The 0 (zero seconds) means to start immediately. Change to whatever value you wish.

    I personally place my scripts in a hidden folder (~/.scripts) and execute them from there.

    Later...
    Bob
     
  5. aigle

    aigle Registered Member

    Joined:
    Dec 14, 2005
    Posts:
    11,047
    Location:
    Saudi Arabia/ Pakistan
    grive is for gdrive client in ubuntu. Normally I run this command in terminal to sync gdrive.
     
  6. vasa1

    vasa1 Registered Member

    Joined:
    May 1, 2010
    Posts:
    4,152
    I don't use grive but it would interesting to know if the delay suggested by Trespasser works for you. When I run apt-cache show grive, the "depends" don't indicate that it's a gtk application.
    Code:
    Depends: libboost-filesystem1.54.0, libboost-program-options1.54.0, libboost-system1.54.0, libc6 (>= 2.14), libcurl3-gnutls (>= 7.16.2), libexpat1 (>= 2.0.1), libgcc1 (>= 1:4.1.1), libgcrypt11 (>= 1.5.1), libjson-c2 (>= 0.10), libstdc++6 (>= 4.4.0)
    I'm curious to know whether "X-GNOME-Autostart-..." will work in this case.

    In case it doesn't, couldn't one could launch grive using a script with a suitable "sleep" period?
     
  7. Trespasser

    Trespasser Registered Member

    Joined:
    Mar 1, 2005
    Posts:
    1,194
    Location:
    Virginia - Appalachian Mtns
    I have some scripts that I delay 30 to 45 seconds (weather alerts and update checks) before they are executed just to be sure that an internet connection is established. Thus, X-GNOME-Autostart-Delay=30 or X-GNOME-Autostart-Delay=45.

    Later...
    Bob
     
  8. Gullible Jones

    Gullible Jones Registered Member

    Joined:
    May 16, 2013
    Posts:
    1,459
    @aigle

    The issue is that rc.local is for root tasks, whereas this is a limited user task. Take a look at the gnome-session-properties app instead, that provides a simple way to add stuff to your session.
     
  9. Mrkvonic

    Mrkvonic Linux Systems Expert

    Joined:
    May 9, 2005
    Posts:
    8,696
    Why do you want to cd into the directory and then run the script? Why just not run it?
    Mrk
     
  10. aigle

    aigle Registered Member

    Joined:
    Dec 14, 2005
    Posts:
    11,047
    Location:
    Saudi Arabia/ Pakistan
    Thanks, will try it.
     
  11. aigle

    aigle Registered Member

    Joined:
    Dec 14, 2005
    Posts:
    11,047
    Location:
    Saudi Arabia/ Pakistan
    I don't know much. There is no script. It is just a command to synh Gdrive and it will not work if I don't cd to the directory first.
     
  12. Trespasser

    Trespasser Registered Member

    Joined:
    Mar 1, 2005
    Posts:
    1,194
    Location:
    Virginia - Appalachian Mtns
    aigle,
    Sorry. The photo you showed from your original post is the rc.local file. I should have picked up on it before now.

    #!/bin/bash
    grive
    exit 0

    If you paste the above code to gedit...save it to your home folder as whatever to wish to name it...example grive-1...make it executable (from terminal type chmod +x grive-1), then...

    [Desktop Entry]
    Type=Application
    Exec=bash -c "~/grive-1"
    Hidden=false
    NoDisplay=false
    X-GNOME-Autostart-enabled=true
    Name[en_US]=Grive
    # change below value to whatever you wish
    X-GNOME-Autostart-Delay=0

    followed by the steps I outlined earlier...it should work.

    Later...

    Bob
     
  13. aigle

    aigle Registered Member

    Joined:
    Dec 14, 2005
    Posts:
    11,047
    Location:
    Saudi Arabia/ Pakistan
    Ok, I followed it except that I changed to

    #!/bin/bash
    cd ~/grive
    grive
    exit 0

    And yes it works!!

    Thanks a lot.
     
Loading...