How do I run a script at startup? (tried several methods but nothing worked) [duplicate]
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
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?
command-line server bash scripts ssh
marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru
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.
add a comment |Â
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?
command-line server bash scripts ssh
marked as duplicate by David Foerster, Fabby, Andrea Corbellini, N0rbert, muru
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
add a comment |Â
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?
command-line server bash scripts ssh
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
command-line server bash scripts ssh
edited May 16 at 15:29
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
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
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
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
add a comment |Â
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
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
edited May 16 at 17:04
Andrea Corbellini
11.6k24362
11.6k24362
answered May 16 at 16:40
user2132767
1
1
add a comment |Â
add a comment |Â
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