Bash script not running at startup from rc.local
I have written a simple bash script:
#!/bin/bash
echo "hi" > log
exit 0
made it executable and its successfully running.
I edited my rc.local to the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/katph/test.sh
exit 0
rc.local is executable:
/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local
What's working:
1.I directly put echo "hi" > /home/katph/log
in rc.local, it works fine.Meaning rc.local runs at startup.
2.If I manually run rc.local with the script, log file is created correctly.
Any suggestion? I'm running Kubuntu14.04.
bash startup
add a comment |
I have written a simple bash script:
#!/bin/bash
echo "hi" > log
exit 0
made it executable and its successfully running.
I edited my rc.local to the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/katph/test.sh
exit 0
rc.local is executable:
/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local
What's working:
1.I directly put echo "hi" > /home/katph/log
in rc.local, it works fine.Meaning rc.local runs at startup.
2.If I manually run rc.local with the script, log file is created correctly.
Any suggestion? I'm running Kubuntu14.04.
bash startup
If you runbash -x /etc/rc.local
, do you see any action?
– Karl Richter
Aug 1 '15 at 8:38
add a comment |
I have written a simple bash script:
#!/bin/bash
echo "hi" > log
exit 0
made it executable and its successfully running.
I edited my rc.local to the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/katph/test.sh
exit 0
rc.local is executable:
/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local
What's working:
1.I directly put echo "hi" > /home/katph/log
in rc.local, it works fine.Meaning rc.local runs at startup.
2.If I manually run rc.local with the script, log file is created correctly.
Any suggestion? I'm running Kubuntu14.04.
bash startup
I have written a simple bash script:
#!/bin/bash
echo "hi" > log
exit 0
made it executable and its successfully running.
I edited my rc.local to the following:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/home/katph/test.sh
exit 0
rc.local is executable:
/$ ls -l /etc/rc.local
-rwxr-xr-x 1 root root 349 Aug 1 13:19 /etc/rc.local
What's working:
1.I directly put echo "hi" > /home/katph/log
in rc.local, it works fine.Meaning rc.local runs at startup.
2.If I manually run rc.local with the script, log file is created correctly.
Any suggestion? I'm running Kubuntu14.04.
bash startup
bash startup
asked Aug 1 '15 at 8:12
Lalit KumarLalit Kumar
13113
13113
If you runbash -x /etc/rc.local
, do you see any action?
– Karl Richter
Aug 1 '15 at 8:38
add a comment |
If you runbash -x /etc/rc.local
, do you see any action?
– Karl Richter
Aug 1 '15 at 8:38
If you run
bash -x /etc/rc.local
, do you see any action?– Karl Richter
Aug 1 '15 at 8:38
If you run
bash -x /etc/rc.local
, do you see any action?– Karl Richter
Aug 1 '15 at 8:38
add a comment |
2 Answers
2
active
oldest
votes
Replace
log
by an absolute path
/home/katph/log
E.G.
#!/bin/bash
echo "hi" > /home/katph/log
exit 0
add a comment |
To see the log of rc.local itself, it's better to run these commands:
systemctl restart rc-local.service
systemctl status rc-local.service
May be it can be help full for better trouble shooting
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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',
autoActivateHeartbeat: false,
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%2faskubuntu.com%2fquestions%2f655296%2fbash-script-not-running-at-startup-from-rc-local%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Replace
log
by an absolute path
/home/katph/log
E.G.
#!/bin/bash
echo "hi" > /home/katph/log
exit 0
add a comment |
Replace
log
by an absolute path
/home/katph/log
E.G.
#!/bin/bash
echo "hi" > /home/katph/log
exit 0
add a comment |
Replace
log
by an absolute path
/home/katph/log
E.G.
#!/bin/bash
echo "hi" > /home/katph/log
exit 0
Replace
log
by an absolute path
/home/katph/log
E.G.
#!/bin/bash
echo "hi" > /home/katph/log
exit 0
edited Aug 1 '15 at 9:19
A.B.
69.1k12172265
69.1k12172265
answered Aug 1 '15 at 8:29
CyrusCyrus
3,22621022
3,22621022
add a comment |
add a comment |
To see the log of rc.local itself, it's better to run these commands:
systemctl restart rc-local.service
systemctl status rc-local.service
May be it can be help full for better trouble shooting
New contributor
add a comment |
To see the log of rc.local itself, it's better to run these commands:
systemctl restart rc-local.service
systemctl status rc-local.service
May be it can be help full for better trouble shooting
New contributor
add a comment |
To see the log of rc.local itself, it's better to run these commands:
systemctl restart rc-local.service
systemctl status rc-local.service
May be it can be help full for better trouble shooting
New contributor
To see the log of rc.local itself, it's better to run these commands:
systemctl restart rc-local.service
systemctl status rc-local.service
May be it can be help full for better trouble shooting
New contributor
New contributor
answered 13 mins ago
AtaeifardAtaeifard
11
11
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f655296%2fbash-script-not-running-at-startup-from-rc-local%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
If you run
bash -x /etc/rc.local
, do you see any action?– Karl Richter
Aug 1 '15 at 8:38