How to run a script after startup on Ubuntu 14.04?
up vote
2
down vote
favorite
I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question.
I have a rails application that I run with mongrel_rails start -e production -p 80
. That command has to be run from the directory of the application, in this case "/var/myapp".
This is the setup:
/etc/mongrel.sh
#!/bin/bash
sleep 15;
cd /var/myapp/
mongrel_rails start -e production -p 80
I added this (sh /etc/mongrel.sh
) before exit 0
in /etc/rc.local
The above does NOT work, but it does work when run manually sh /etc/mongrel.sh
. I have also tried running this in a screen session using: screen -d -m *command*
.
Any suggestions to get this working as desired? I need this application running after boot.
linux ubuntu bash shell-script
add a comment |
up vote
2
down vote
favorite
I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question.
I have a rails application that I run with mongrel_rails start -e production -p 80
. That command has to be run from the directory of the application, in this case "/var/myapp".
This is the setup:
/etc/mongrel.sh
#!/bin/bash
sleep 15;
cd /var/myapp/
mongrel_rails start -e production -p 80
I added this (sh /etc/mongrel.sh
) before exit 0
in /etc/rc.local
The above does NOT work, but it does work when run manually sh /etc/mongrel.sh
. I have also tried running this in a screen session using: screen -d -m *command*
.
Any suggestions to get this working as desired? I need this application running after boot.
linux ubuntu bash shell-script
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question.
I have a rails application that I run with mongrel_rails start -e production -p 80
. That command has to be run from the directory of the application, in this case "/var/myapp".
This is the setup:
/etc/mongrel.sh
#!/bin/bash
sleep 15;
cd /var/myapp/
mongrel_rails start -e production -p 80
I added this (sh /etc/mongrel.sh
) before exit 0
in /etc/rc.local
The above does NOT work, but it does work when run manually sh /etc/mongrel.sh
. I have also tried running this in a screen session using: screen -d -m *command*
.
Any suggestions to get this working as desired? I need this application running after boot.
linux ubuntu bash shell-script
I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question.
I have a rails application that I run with mongrel_rails start -e production -p 80
. That command has to be run from the directory of the application, in this case "/var/myapp".
This is the setup:
/etc/mongrel.sh
#!/bin/bash
sleep 15;
cd /var/myapp/
mongrel_rails start -e production -p 80
I added this (sh /etc/mongrel.sh
) before exit 0
in /etc/rc.local
The above does NOT work, but it does work when run manually sh /etc/mongrel.sh
. I have also tried running this in a screen session using: screen -d -m *command*
.
Any suggestions to get this working as desired? I need this application running after boot.
linux ubuntu bash shell-script
linux ubuntu bash shell-script
asked Feb 23 '15 at 19:39
Ralph
1451111
1451111
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
You can add your script in cron job.
To add the script in cron job follow below steps
- Open terminal with root access.
- Run crontab -e this command will allow you to edit your cron.
- Add the line @reboot sh /etc/mongrel.sh
The above process will execute that script once your computer boots up.
I found a post suggesting the same. I have runcrontab -e
and added@reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebootedreboot
, didn't help.
– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output ofcat /var/log/syslog
.
– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
|
show 5 more comments
up vote
0
down vote
Call /etc/mongrel.sh
from /etc/rc.local
. This script called rc.local
is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,
Thank you for your answer but I don't think you read the question. The script is already being called from/etc/rc.local
.
– Ralph
Feb 25 '15 at 16:49
add a comment |
up vote
0
down vote
In rc.conf
you have have to tell the system where sh
is. So use:
/bin/bash/sh /etc/mongrel.sh
That will allow the system to run the script.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f881575%2fhow-to-run-a-script-after-startup-on-ubuntu-14-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You can add your script in cron job.
To add the script in cron job follow below steps
- Open terminal with root access.
- Run crontab -e this command will allow you to edit your cron.
- Add the line @reboot sh /etc/mongrel.sh
The above process will execute that script once your computer boots up.
I found a post suggesting the same. I have runcrontab -e
and added@reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebootedreboot
, didn't help.
– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output ofcat /var/log/syslog
.
– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
|
show 5 more comments
up vote
1
down vote
You can add your script in cron job.
To add the script in cron job follow below steps
- Open terminal with root access.
- Run crontab -e this command will allow you to edit your cron.
- Add the line @reboot sh /etc/mongrel.sh
The above process will execute that script once your computer boots up.
I found a post suggesting the same. I have runcrontab -e
and added@reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebootedreboot
, didn't help.
– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output ofcat /var/log/syslog
.
– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
|
show 5 more comments
up vote
1
down vote
up vote
1
down vote
You can add your script in cron job.
To add the script in cron job follow below steps
- Open terminal with root access.
- Run crontab -e this command will allow you to edit your cron.
- Add the line @reboot sh /etc/mongrel.sh
The above process will execute that script once your computer boots up.
You can add your script in cron job.
To add the script in cron job follow below steps
- Open terminal with root access.
- Run crontab -e this command will allow you to edit your cron.
- Add the line @reboot sh /etc/mongrel.sh
The above process will execute that script once your computer boots up.
answered Feb 23 '15 at 19:52
vembutech
5,35811317
5,35811317
I found a post suggesting the same. I have runcrontab -e
and added@reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebootedreboot
, didn't help.
– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output ofcat /var/log/syslog
.
– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
|
show 5 more comments
I found a post suggesting the same. I have runcrontab -e
and added@reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebootedreboot
, didn't help.
– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output ofcat /var/log/syslog
.
– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
I found a post suggesting the same. I have run
crontab -e
and added @reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebooted reboot
, didn't help.– Ralph
Feb 23 '15 at 20:30
I found a post suggesting the same. I have run
crontab -e
and added @reboot sh /etc/mongrel.sh
to the file. Exited (automatically saved the file) and rebooted reboot
, didn't help.– Ralph
Feb 23 '15 at 20:30
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
Can you check Syslog file and check is it have any information about mongrel.sh script? and also under which you are try to run the script?
– vembutech
Feb 23 '15 at 21:20
This is the output of
cat /var/log/syslog
.– Ralph
Feb 24 '15 at 9:01
This is the output of
cat /var/log/syslog
.– Ralph
Feb 24 '15 at 9:01
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /usr/sbin/cron[1874]: (CRON) INFO (Running @reboot jobs)
– Ralph
Feb 24 '15 at 9:02
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
Feb 24 08:50:57 vaatia-22-02-15 /USR/SBIN/CRON[1901]: (root) CMD (sh /etc/mongrel.sh)
– Ralph
Feb 24 '15 at 9:03
|
show 5 more comments
up vote
0
down vote
Call /etc/mongrel.sh
from /etc/rc.local
. This script called rc.local
is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,
Thank you for your answer but I don't think you read the question. The script is already being called from/etc/rc.local
.
– Ralph
Feb 25 '15 at 16:49
add a comment |
up vote
0
down vote
Call /etc/mongrel.sh
from /etc/rc.local
. This script called rc.local
is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,
Thank you for your answer but I don't think you read the question. The script is already being called from/etc/rc.local
.
– Ralph
Feb 25 '15 at 16:49
add a comment |
up vote
0
down vote
up vote
0
down vote
Call /etc/mongrel.sh
from /etc/rc.local
. This script called rc.local
is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,
Call /etc/mongrel.sh
from /etc/rc.local
. This script called rc.local
is executed after all the normal system services are started, at the end of the process of switching to a multiuser runlevel, so you might use it to start your service,
answered Feb 25 '15 at 13:08
jcbermu
15.5k24354
15.5k24354
Thank you for your answer but I don't think you read the question. The script is already being called from/etc/rc.local
.
– Ralph
Feb 25 '15 at 16:49
add a comment |
Thank you for your answer but I don't think you read the question. The script is already being called from/etc/rc.local
.
– Ralph
Feb 25 '15 at 16:49
Thank you for your answer but I don't think you read the question. The script is already being called from
/etc/rc.local
.– Ralph
Feb 25 '15 at 16:49
Thank you for your answer but I don't think you read the question. The script is already being called from
/etc/rc.local
.– Ralph
Feb 25 '15 at 16:49
add a comment |
up vote
0
down vote
In rc.conf
you have have to tell the system where sh
is. So use:
/bin/bash/sh /etc/mongrel.sh
That will allow the system to run the script.
add a comment |
up vote
0
down vote
In rc.conf
you have have to tell the system where sh
is. So use:
/bin/bash/sh /etc/mongrel.sh
That will allow the system to run the script.
add a comment |
up vote
0
down vote
up vote
0
down vote
In rc.conf
you have have to tell the system where sh
is. So use:
/bin/bash/sh /etc/mongrel.sh
That will allow the system to run the script.
In rc.conf
you have have to tell the system where sh
is. So use:
/bin/bash/sh /etc/mongrel.sh
That will allow the system to run the script.
answered Dec 4 at 4:37
LifeBoy
10016
10016
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f881575%2fhow-to-run-a-script-after-startup-on-ubuntu-14-04%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown