How to run a program on boot up?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite
1












So I have this program which I manually run as root :



sudo gammu-smsd -c /etc/gammu-smsdrc -d 


What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .



Is it ok to just edit root's crontab and stick this command there? Or there's some other way?



(Im using Ubuntu 11.04.)










share|improve this question















migrated from stackoverflow.com Sep 28 '11 at 10:32


This question came from our site for professional and enthusiast programmers.










  • 1




    You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
    – Johan
    Sep 28 '11 at 10:38










  • You might first ask yourself if you want that to be run before or after a user logs in.
    – rozcietrzewiacz
    Sep 28 '11 at 11:02







  • 1




    It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
    – whoami
    Sep 28 '11 at 11:07










  • I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
    – r2b2
    Sep 28 '11 at 14:30














up vote
5
down vote

favorite
1












So I have this program which I manually run as root :



sudo gammu-smsd -c /etc/gammu-smsdrc -d 


What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .



Is it ok to just edit root's crontab and stick this command there? Or there's some other way?



(Im using Ubuntu 11.04.)










share|improve this question















migrated from stackoverflow.com Sep 28 '11 at 10:32


This question came from our site for professional and enthusiast programmers.










  • 1




    You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
    – Johan
    Sep 28 '11 at 10:38










  • You might first ask yourself if you want that to be run before or after a user logs in.
    – rozcietrzewiacz
    Sep 28 '11 at 11:02







  • 1




    It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
    – whoami
    Sep 28 '11 at 11:07










  • I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
    – r2b2
    Sep 28 '11 at 14:30












up vote
5
down vote

favorite
1









up vote
5
down vote

favorite
1






1





So I have this program which I manually run as root :



sudo gammu-smsd -c /etc/gammu-smsdrc -d 


What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .



Is it ok to just edit root's crontab and stick this command there? Or there's some other way?



(Im using Ubuntu 11.04.)










share|improve this question















So I have this program which I manually run as root :



sudo gammu-smsd -c /etc/gammu-smsdrc -d 


What this does is it runs the Gammu (software to manage gsm modems) and 'daemonize' it. My problem is I want this program to automatically run on boot up .



Is it ok to just edit root's crontab and stick this command there? Or there's some other way?



(Im using Ubuntu 11.04.)







linux boot init-script






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 28 '11 at 11:41









Stéphane Gimenez

18.8k15074




18.8k15074










asked Sep 28 '11 at 9:35









r2b2

143126




143126




migrated from stackoverflow.com Sep 28 '11 at 10:32


This question came from our site for professional and enthusiast programmers.






migrated from stackoverflow.com Sep 28 '11 at 10:32


This question came from our site for professional and enthusiast programmers.









  • 1




    You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
    – Johan
    Sep 28 '11 at 10:38










  • You might first ask yourself if you want that to be run before or after a user logs in.
    – rozcietrzewiacz
    Sep 28 '11 at 11:02







  • 1




    It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
    – whoami
    Sep 28 '11 at 11:07










  • I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
    – r2b2
    Sep 28 '11 at 14:30












  • 1




    You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
    – Johan
    Sep 28 '11 at 10:38










  • You might first ask yourself if you want that to be run before or after a user logs in.
    – rozcietrzewiacz
    Sep 28 '11 at 11:02







  • 1




    It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
    – whoami
    Sep 28 '11 at 11:07










  • I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
    – r2b2
    Sep 28 '11 at 14:30







1




1




You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
– Johan
Sep 28 '11 at 10:38




You probably don't need the sudo when you put it in the startup files since most stuff there is executed by root.
– Johan
Sep 28 '11 at 10:38












You might first ask yourself if you want that to be run before or after a user logs in.
– rozcietrzewiacz
Sep 28 '11 at 11:02





You might first ask yourself if you want that to be run before or after a user logs in.
– rozcietrzewiacz
Sep 28 '11 at 11:02





1




1




It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
– whoami
Sep 28 '11 at 11:07




It maybe worth looking at creating init.d scripts for your daemon, However your requirement so up to you.
– whoami
Sep 28 '11 at 11:07












I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
– r2b2
Sep 28 '11 at 14:30




I would like to run before a user logs in. The thing is I want my server to run my programs (not just gammu) even if im not around during a power failure in which the computer reboots.
– r2b2
Sep 28 '11 at 14:30










4 Answers
4






active

oldest

votes

















up vote
6
down vote



accepted










How about /etc/rc.local?



This will be executed last in the startup sequence.






share|improve this answer




















  • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
    – GusDeCooL
    May 15 '13 at 16:50


















up vote
0
down vote













Here is how on how to add a startup script to be run at bootup. You can find more information here.






share|improve this answer
















  • 1




    The link you gave is very outdated. From what I know, the booting procedure has much changed since.
    – rozcietrzewiacz
    Sep 28 '11 at 11:00

















up vote
0
down vote













May this help you ?



http://www.howtogeek.com/howto/ubuntu/how-to-add-a-program-to-the-ubuntu-startup-list-after-login/




Or just add it in the /etc/profile



or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/



Indeed, remove the sudo !
(but you will need it to do the edit or to add the command, so...)






share|improve this answer


















  • 1




    it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
    – r2b2
    Sep 28 '11 at 9:49










  • see my edit : add it in the system-wide startup file
    – Louis
    Sep 28 '11 at 10:01










  • Louis: do I need to remove sudo if i follow that guide?
    – r2b2
    Sep 28 '11 at 14:23

















up vote
0
down vote













You can use crontab for this.

Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).

Add following line at the end:



@reboot <command>


Examples:



  • @reboot my_script.sh

  • @reboot python my_script.py arg1 arg2

Finally use contab -l to make sure your script was added to the list.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21593%2fhow-to-run-a-program-on-boot-up%23new-answer', 'question_page');

    );

    Post as a guest






























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    How about /etc/rc.local?



    This will be executed last in the startup sequence.






    share|improve this answer




















    • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
      – GusDeCooL
      May 15 '13 at 16:50















    up vote
    6
    down vote



    accepted










    How about /etc/rc.local?



    This will be executed last in the startup sequence.






    share|improve this answer




















    • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
      – GusDeCooL
      May 15 '13 at 16:50













    up vote
    6
    down vote



    accepted







    up vote
    6
    down vote



    accepted






    How about /etc/rc.local?



    This will be executed last in the startup sequence.






    share|improve this answer












    How about /etc/rc.local?



    This will be executed last in the startup sequence.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 28 '11 at 10:40









    Johan

    3,15411628




    3,15411628











    • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
      – GusDeCooL
      May 15 '13 at 16:50

















    • add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
      – GusDeCooL
      May 15 '13 at 16:50
















    add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
    – GusDeCooL
    May 15 '13 at 16:50





    add sleep 1m before gammu-smsd -d. I know this is not recommended, but this is the easy way to make it working. You might need also look for creating init.d script
    – GusDeCooL
    May 15 '13 at 16:50













    up vote
    0
    down vote













    Here is how on how to add a startup script to be run at bootup. You can find more information here.






    share|improve this answer
















    • 1




      The link you gave is very outdated. From what I know, the booting procedure has much changed since.
      – rozcietrzewiacz
      Sep 28 '11 at 11:00














    up vote
    0
    down vote













    Here is how on how to add a startup script to be run at bootup. You can find more information here.






    share|improve this answer
















    • 1




      The link you gave is very outdated. From what I know, the booting procedure has much changed since.
      – rozcietrzewiacz
      Sep 28 '11 at 11:00












    up vote
    0
    down vote










    up vote
    0
    down vote









    Here is how on how to add a startup script to be run at bootup. You can find more information here.






    share|improve this answer












    Here is how on how to add a startup script to be run at bootup. You can find more information here.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 28 '11 at 10:25









    Praveen Sripati

    1214




    1214







    • 1




      The link you gave is very outdated. From what I know, the booting procedure has much changed since.
      – rozcietrzewiacz
      Sep 28 '11 at 11:00












    • 1




      The link you gave is very outdated. From what I know, the booting procedure has much changed since.
      – rozcietrzewiacz
      Sep 28 '11 at 11:00







    1




    1




    The link you gave is very outdated. From what I know, the booting procedure has much changed since.
    – rozcietrzewiacz
    Sep 28 '11 at 11:00




    The link you gave is very outdated. From what I know, the booting procedure has much changed since.
    – rozcietrzewiacz
    Sep 28 '11 at 11:00










    up vote
    0
    down vote













    May this help you ?



    http://www.howtogeek.com/howto/ubuntu/how-to-add-a-program-to-the-ubuntu-startup-list-after-login/




    Or just add it in the /etc/profile



    or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/



    Indeed, remove the sudo !
    (but you will need it to do the edit or to add the command, so...)






    share|improve this answer


















    • 1




      it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
      – r2b2
      Sep 28 '11 at 9:49










    • see my edit : add it in the system-wide startup file
      – Louis
      Sep 28 '11 at 10:01










    • Louis: do I need to remove sudo if i follow that guide?
      – r2b2
      Sep 28 '11 at 14:23














    up vote
    0
    down vote













    May this help you ?



    http://www.howtogeek.com/howto/ubuntu/how-to-add-a-program-to-the-ubuntu-startup-list-after-login/




    Or just add it in the /etc/profile



    or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/



    Indeed, remove the sudo !
    (but you will need it to do the edit or to add the command, so...)






    share|improve this answer


















    • 1




      it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
      – r2b2
      Sep 28 '11 at 9:49










    • see my edit : add it in the system-wide startup file
      – Louis
      Sep 28 '11 at 10:01










    • Louis: do I need to remove sudo if i follow that guide?
      – r2b2
      Sep 28 '11 at 14:23












    up vote
    0
    down vote










    up vote
    0
    down vote









    May this help you ?



    http://www.howtogeek.com/howto/ubuntu/how-to-add-a-program-to-the-ubuntu-startup-list-after-login/




    Or just add it in the /etc/profile



    or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/



    Indeed, remove the sudo !
    (but you will need it to do the edit or to add the command, so...)






    share|improve this answer














    May this help you ?



    http://www.howtogeek.com/howto/ubuntu/how-to-add-a-program-to-the-ubuntu-startup-list-after-login/




    Or just add it in the /etc/profile



    or do add it the recommended way : http://embraceubuntu.com/2005/09/07/adding-a-startup-script-to-be-run-at-bootup/



    Indeed, remove the sudo !
    (but you will need it to do the edit or to add the command, so...)







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 28 '11 at 20:00









    Community♦

    1




    1










    answered Sep 28 '11 at 9:39









    Louis

    1012




    1012







    • 1




      it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
      – r2b2
      Sep 28 '11 at 9:49










    • see my edit : add it in the system-wide startup file
      – Louis
      Sep 28 '11 at 10:01










    • Louis: do I need to remove sudo if i follow that guide?
      – r2b2
      Sep 28 '11 at 14:23












    • 1




      it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
      – r2b2
      Sep 28 '11 at 9:49










    • see my edit : add it in the system-wide startup file
      – Louis
      Sep 28 '11 at 10:01










    • Louis: do I need to remove sudo if i follow that guide?
      – r2b2
      Sep 28 '11 at 14:23







    1




    1




    it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
    – r2b2
    Sep 28 '11 at 9:49




    it executes the program after the login, i was hoping something that gets executed before that, or during the login window is shown ,or without needing to login
    – r2b2
    Sep 28 '11 at 9:49












    see my edit : add it in the system-wide startup file
    – Louis
    Sep 28 '11 at 10:01




    see my edit : add it in the system-wide startup file
    – Louis
    Sep 28 '11 at 10:01












    Louis: do I need to remove sudo if i follow that guide?
    – r2b2
    Sep 28 '11 at 14:23




    Louis: do I need to remove sudo if i follow that guide?
    – r2b2
    Sep 28 '11 at 14:23










    up vote
    0
    down vote













    You can use crontab for this.

    Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).

    Add following line at the end:



    @reboot <command>


    Examples:



    • @reboot my_script.sh

    • @reboot python my_script.py arg1 arg2

    Finally use contab -l to make sure your script was added to the list.






    share|improve this answer
























      up vote
      0
      down vote













      You can use crontab for this.

      Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).

      Add following line at the end:



      @reboot <command>


      Examples:



      • @reboot my_script.sh

      • @reboot python my_script.py arg1 arg2

      Finally use contab -l to make sure your script was added to the list.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        You can use crontab for this.

        Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).

        Add following line at the end:



        @reboot <command>


        Examples:



        • @reboot my_script.sh

        • @reboot python my_script.py arg1 arg2

        Finally use contab -l to make sure your script was added to the list.






        share|improve this answer












        You can use crontab for this.

        Use crontab -e to edit user's crontab (A list of start-up scripts that users have added).

        Add following line at the end:



        @reboot <command>


        Examples:



        • @reboot my_script.sh

        • @reboot python my_script.py arg1 arg2

        Finally use contab -l to make sure your script was added to the list.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Jithin Pavithran

        1185




        1185



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f21593%2fhow-to-run-a-program-on-boot-up%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay