How do I run a script at startup? (tried several methods but nothing worked) [duplicate]

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








up vote
-1
down vote

favorite













This question already has an answer here:



  • How to run scripts on start up?

    9 answers



I have a script in a folder:



/home/ubuntu/jasperreports-server-cp-6.3.0/ctlscript.sh


I need this script to run every time the server starts. Usually the server shuts down on Friday evenings and starts on Monday morning. What do I need to do in order to make this happen?.



How I manually start the script:



I will ssh to the server, and then go to this location /home/ubuntu/jasperreports-server-cp-6.3.0



and then run ./ctlscript.sh* start command manually.



But I am unable to start this script at the server start on Monday automatically.



I tried using rc.local , and also creating a script in /etc/init.d, I did follow this but it didn't work either How do I run a script at start up?.



Does anyone have any other suggestions? Or is my procedure wrong?







share|improve this question














marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
May 17 at 1:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
    – Emily
    May 15 at 16:56










  • @Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
    – user2132767
    May 15 at 17:30










  • You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
    – eDen
    May 15 at 18:07










  • First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
    – user2132767
    May 16 at 16:23















up vote
-1
down vote

favorite













This question already has an answer here:



  • How to run scripts on start up?

    9 answers



I have a script in a folder:



/home/ubuntu/jasperreports-server-cp-6.3.0/ctlscript.sh


I need this script to run every time the server starts. Usually the server shuts down on Friday evenings and starts on Monday morning. What do I need to do in order to make this happen?.



How I manually start the script:



I will ssh to the server, and then go to this location /home/ubuntu/jasperreports-server-cp-6.3.0



and then run ./ctlscript.sh* start command manually.



But I am unable to start this script at the server start on Monday automatically.



I tried using rc.local , and also creating a script in /etc/init.d, I did follow this but it didn't work either How do I run a script at start up?.



Does anyone have any other suggestions? Or is my procedure wrong?







share|improve this question














marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
May 17 at 1:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
    – Emily
    May 15 at 16:56










  • @Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
    – user2132767
    May 15 at 17:30










  • You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
    – eDen
    May 15 at 18:07










  • First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
    – user2132767
    May 16 at 16:23













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:



  • How to run scripts on start up?

    9 answers



I have a script in a folder:



/home/ubuntu/jasperreports-server-cp-6.3.0/ctlscript.sh


I need this script to run every time the server starts. Usually the server shuts down on Friday evenings and starts on Monday morning. What do I need to do in order to make this happen?.



How I manually start the script:



I will ssh to the server, and then go to this location /home/ubuntu/jasperreports-server-cp-6.3.0



and then run ./ctlscript.sh* start command manually.



But I am unable to start this script at the server start on Monday automatically.



I tried using rc.local , and also creating a script in /etc/init.d, I did follow this but it didn't work either How do I run a script at start up?.



Does anyone have any other suggestions? Or is my procedure wrong?







share|improve this question















This question already has an answer here:



  • How to run scripts on start up?

    9 answers



I have a script in a folder:



/home/ubuntu/jasperreports-server-cp-6.3.0/ctlscript.sh


I need this script to run every time the server starts. Usually the server shuts down on Friday evenings and starts on Monday morning. What do I need to do in order to make this happen?.



How I manually start the script:



I will ssh to the server, and then go to this location /home/ubuntu/jasperreports-server-cp-6.3.0



and then run ./ctlscript.sh* start command manually.



But I am unable to start this script at the server start on Monday automatically.



I tried using rc.local , and also creating a script in /etc/init.d, I did follow this but it didn't work either How do I run a script at start up?.



Does anyone have any other suggestions? Or is my procedure wrong?





This question already has an answer here:



  • How to run scripts on start up?

    9 answers









share|improve this question













share|improve this question




share|improve this question








edited May 16 at 15:29









Zanna

47.9k13118227




47.9k13118227










asked May 15 at 16:26









user2132767

1




1




marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
May 17 at 1:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru bash
Users with the  bash badge can single-handedly close bash questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
May 17 at 1:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.













  • Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
    – Emily
    May 15 at 16:56










  • @Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
    – user2132767
    May 15 at 17:30










  • You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
    – eDen
    May 15 at 18:07










  • First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
    – user2132767
    May 16 at 16:23

















  • Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
    – Emily
    May 15 at 16:56










  • @Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
    – user2132767
    May 15 at 17:30










  • You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
    – eDen
    May 15 at 18:07










  • First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
    – user2132767
    May 16 at 16:23
















Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
– Emily
May 15 at 16:56




Have you tried editing your cron table? See this answer to "How to run scripts on start up?"
– Emily
May 15 at 16:56












@Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
– user2132767
May 15 at 17:30




@Emily the link I provided in the question has one of the method that you suggested, but I tried all 3 methods and it din't work. I am not sure as I have to run the script ctlscript.sh with a start next to it. not sure if it what needed much attention, and how to modify the case that suits this scenario.
– user2132767
May 15 at 17:30












You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
– eDen
May 15 at 18:07




You can use systemd.service. Detailed procedure can be found here : How to write startup script for systemd.
– eDen
May 15 at 18:07












First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
– user2132767
May 16 at 16:23





First I created vi script.sh, and added "#!/bin/sh cd /home/ubuntu/jasperreports-server-cp-6.3.0 ./ctlscript.sh start" and then used "crontab -e" command,which opens a file and I have added "@reboot sh /path/to/my/script.sh" . so when my server reboots or starts , the script is run every time. it worked for me. thank you all
– user2132767
May 16 at 16:23











1 Answer
1






active

oldest

votes

















up vote
0
down vote













I solved it this time



First I created a runnable script



vi script.sh


at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh



#!/bin/sh
cd /home/ubuntu/jasperreports-server-cp-6.3.0
./ctlscript.sh start


(I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)



and then saved it. now gave the file script.sh permission to exec using



chmod 700 script.sh


(You can give permissions based on your needs, all we need is the script to be give permission for execution)



And now opened crontab -e command, and added



@reboot sh /home/ubuntu/script.sh


so when my server reboots or starts , the script is run every time. it worked for me. thank you all






share|improve this answer





























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I solved it this time



    First I created a runnable script



    vi script.sh


    at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh



    #!/bin/sh
    cd /home/ubuntu/jasperreports-server-cp-6.3.0
    ./ctlscript.sh start


    (I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)



    and then saved it. now gave the file script.sh permission to exec using



    chmod 700 script.sh


    (You can give permissions based on your needs, all we need is the script to be give permission for execution)



    And now opened crontab -e command, and added



    @reboot sh /home/ubuntu/script.sh


    so when my server reboots or starts , the script is run every time. it worked for me. thank you all






    share|improve this answer


























      up vote
      0
      down vote













      I solved it this time



      First I created a runnable script



      vi script.sh


      at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh



      #!/bin/sh
      cd /home/ubuntu/jasperreports-server-cp-6.3.0
      ./ctlscript.sh start


      (I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)



      and then saved it. now gave the file script.sh permission to exec using



      chmod 700 script.sh


      (You can give permissions based on your needs, all we need is the script to be give permission for execution)



      And now opened crontab -e command, and added



      @reboot sh /home/ubuntu/script.sh


      so when my server reboots or starts , the script is run every time. it worked for me. thank you all






      share|improve this answer
























        up vote
        0
        down vote










        up vote
        0
        down vote









        I solved it this time



        First I created a runnable script



        vi script.sh


        at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh



        #!/bin/sh
        cd /home/ubuntu/jasperreports-server-cp-6.3.0
        ./ctlscript.sh start


        (I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)



        and then saved it. now gave the file script.sh permission to exec using



        chmod 700 script.sh


        (You can give permissions based on your needs, all we need is the script to be give permission for execution)



        And now opened crontab -e command, and added



        @reboot sh /home/ubuntu/script.sh


        so when my server reboots or starts , the script is run every time. it worked for me. thank you all






        share|improve this answer














        I solved it this time



        First I created a runnable script



        vi script.sh


        at home location that is at /home/ubuntu (you can create it at any location,but remember you have to give the same location in crontab -e) and then added these lines to the file script.sh



        #!/bin/sh
        cd /home/ubuntu/jasperreports-server-cp-6.3.0
        ./ctlscript.sh start


        (I have a parameter to use start , but for you it might be a different, so here it should be the command that you use manualy to run the script, in simile it should be the same as how you run the script manually)



        and then saved it. now gave the file script.sh permission to exec using



        chmod 700 script.sh


        (You can give permissions based on your needs, all we need is the script to be give permission for execution)



        And now opened crontab -e command, and added



        @reboot sh /home/ubuntu/script.sh


        so when my server reboots or starts , the script is run every time. it worked for me. thank you all







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 16 at 17:04









        Andrea Corbellini

        11.6k24362




        11.6k24362










        answered May 16 at 16:40









        user2132767

        1




        1












            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491