How to run script on startup with root
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I have my little script to start an application and do some more things on my Ubuntu 16.04 which looks like this:
#!/bin/bash
./ROC-smi/rocm-smi -d 1 --setfan 90
./ROC-smi/rocm-smi -d 0 --setfan 90
./ROC-smi/rocm-smi -d 2 --setfan 110
./ROC-smi/rocm-smi -d 3 --setfan 110
./ROC-smi/rocm-smi -d 4 --setfan 110
cd teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
I want to autostart it with sudo. I tried rc.local with:
sh /path/to/my/script.sh
exit 0
I also tried using crontab with:
@reboot /path/to/my/script.sh
nothing worked, rc.local didn't show any errors when I tested it with
sudo /etc/init.d/rc.local start
, but when I type sudo screen -xr
or screen -ls
or sudo screen -ls
, I always got a message that there's no screen to attach.
bash scripts cron root autostart
add a comment |
I have my little script to start an application and do some more things on my Ubuntu 16.04 which looks like this:
#!/bin/bash
./ROC-smi/rocm-smi -d 1 --setfan 90
./ROC-smi/rocm-smi -d 0 --setfan 90
./ROC-smi/rocm-smi -d 2 --setfan 110
./ROC-smi/rocm-smi -d 3 --setfan 110
./ROC-smi/rocm-smi -d 4 --setfan 110
cd teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
I want to autostart it with sudo. I tried rc.local with:
sh /path/to/my/script.sh
exit 0
I also tried using crontab with:
@reboot /path/to/my/script.sh
nothing worked, rc.local didn't show any errors when I tested it with
sudo /etc/init.d/rc.local start
, but when I type sudo screen -xr
or screen -ls
or sudo screen -ls
, I always got a message that there's no screen to attach.
bash scripts cron root autostart
2
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33
add a comment |
I have my little script to start an application and do some more things on my Ubuntu 16.04 which looks like this:
#!/bin/bash
./ROC-smi/rocm-smi -d 1 --setfan 90
./ROC-smi/rocm-smi -d 0 --setfan 90
./ROC-smi/rocm-smi -d 2 --setfan 110
./ROC-smi/rocm-smi -d 3 --setfan 110
./ROC-smi/rocm-smi -d 4 --setfan 110
cd teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
I want to autostart it with sudo. I tried rc.local with:
sh /path/to/my/script.sh
exit 0
I also tried using crontab with:
@reboot /path/to/my/script.sh
nothing worked, rc.local didn't show any errors when I tested it with
sudo /etc/init.d/rc.local start
, but when I type sudo screen -xr
or screen -ls
or sudo screen -ls
, I always got a message that there's no screen to attach.
bash scripts cron root autostart
I have my little script to start an application and do some more things on my Ubuntu 16.04 which looks like this:
#!/bin/bash
./ROC-smi/rocm-smi -d 1 --setfan 90
./ROC-smi/rocm-smi -d 0 --setfan 90
./ROC-smi/rocm-smi -d 2 --setfan 110
./ROC-smi/rocm-smi -d 3 --setfan 110
./ROC-smi/rocm-smi -d 4 --setfan 110
cd teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
I want to autostart it with sudo. I tried rc.local with:
sh /path/to/my/script.sh
exit 0
I also tried using crontab with:
@reboot /path/to/my/script.sh
nothing worked, rc.local didn't show any errors when I tested it with
sudo /etc/init.d/rc.local start
, but when I type sudo screen -xr
or screen -ls
or sudo screen -ls
, I always got a message that there's no screen to attach.
bash scripts cron root autostart
bash scripts cron root autostart
edited Mar 22 at 15:32
terdon♦
67.5k13139223
67.5k13139223
asked Mar 22 at 15:27
mil0szmil0sz
42
42
2
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33
add a comment |
2
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33
2
2
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33
add a comment |
1 Answer
1
active
oldest
votes
I see there might be two problems with what you're doing.
1. Check your scrip has permission to run
Just chmod-it like
chmod +x /path/to/my/script.sh
chmod +x /path/to/ROC-smi/rocm-smi
Otherwise it won't run.
2. Fix wrong paths
When you have ./ROC-smi/rocm-smi
you're telling bash to run ROC-smi/rocm-smi
from the path you're calling the script, not from where the script is located. This means that if you call the script from /root
, bash will look for /root/ROC-smi/rocm-smi
and not for /path/to/my/script/ROC-smi/rocm-smi
.
The most straightforward solution is
#!/bin/bash
/absolute/path/to/ROC-smi/rocm-smi -d 1 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 0 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 2 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 3 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
However, if that script can run from anywhere, this quick patch will do as pointed out in this answer
#!/bin/bash
scriptdir="$(dirname "$0")"
cd $scriptdir"
ROC-smi/rocm-smi -d 1 --setfan 90
...
Now, $0
is unreliable (see here) so perhaps you want to try cd "${BASH_SOURCE%/*}"
instead. I would try
#!/bin/bash
cd ${BASH_SOURCE%/*}
ROC-smi/rocm-smi -d 1 --setfan 90
ROC-smi/rocm-smi -d 0 --setfan 90
ROC-smi/rocm-smi -d 2 --setfan 110
ROC-smi/rocm-smi -d 3 --setfan 110
ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIKrc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg../ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…
– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Letscript.sh
be#!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add@reboot /path/to/script.sh
. Reboot and check if works (it should). also checkgrep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
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%2f1127873%2fhow-to-run-script-on-startup-with-root%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I see there might be two problems with what you're doing.
1. Check your scrip has permission to run
Just chmod-it like
chmod +x /path/to/my/script.sh
chmod +x /path/to/ROC-smi/rocm-smi
Otherwise it won't run.
2. Fix wrong paths
When you have ./ROC-smi/rocm-smi
you're telling bash to run ROC-smi/rocm-smi
from the path you're calling the script, not from where the script is located. This means that if you call the script from /root
, bash will look for /root/ROC-smi/rocm-smi
and not for /path/to/my/script/ROC-smi/rocm-smi
.
The most straightforward solution is
#!/bin/bash
/absolute/path/to/ROC-smi/rocm-smi -d 1 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 0 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 2 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 3 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
However, if that script can run from anywhere, this quick patch will do as pointed out in this answer
#!/bin/bash
scriptdir="$(dirname "$0")"
cd $scriptdir"
ROC-smi/rocm-smi -d 1 --setfan 90
...
Now, $0
is unreliable (see here) so perhaps you want to try cd "${BASH_SOURCE%/*}"
instead. I would try
#!/bin/bash
cd ${BASH_SOURCE%/*}
ROC-smi/rocm-smi -d 1 --setfan 90
ROC-smi/rocm-smi -d 0 --setfan 90
ROC-smi/rocm-smi -d 2 --setfan 110
ROC-smi/rocm-smi -d 3 --setfan 110
ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIKrc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg../ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…
– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Letscript.sh
be#!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add@reboot /path/to/script.sh
. Reboot and check if works (it should). also checkgrep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
add a comment |
I see there might be two problems with what you're doing.
1. Check your scrip has permission to run
Just chmod-it like
chmod +x /path/to/my/script.sh
chmod +x /path/to/ROC-smi/rocm-smi
Otherwise it won't run.
2. Fix wrong paths
When you have ./ROC-smi/rocm-smi
you're telling bash to run ROC-smi/rocm-smi
from the path you're calling the script, not from where the script is located. This means that if you call the script from /root
, bash will look for /root/ROC-smi/rocm-smi
and not for /path/to/my/script/ROC-smi/rocm-smi
.
The most straightforward solution is
#!/bin/bash
/absolute/path/to/ROC-smi/rocm-smi -d 1 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 0 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 2 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 3 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
However, if that script can run from anywhere, this quick patch will do as pointed out in this answer
#!/bin/bash
scriptdir="$(dirname "$0")"
cd $scriptdir"
ROC-smi/rocm-smi -d 1 --setfan 90
...
Now, $0
is unreliable (see here) so perhaps you want to try cd "${BASH_SOURCE%/*}"
instead. I would try
#!/bin/bash
cd ${BASH_SOURCE%/*}
ROC-smi/rocm-smi -d 1 --setfan 90
ROC-smi/rocm-smi -d 0 --setfan 90
ROC-smi/rocm-smi -d 2 --setfan 110
ROC-smi/rocm-smi -d 3 --setfan 110
ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIKrc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg../ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…
– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Letscript.sh
be#!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add@reboot /path/to/script.sh
. Reboot and check if works (it should). also checkgrep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
add a comment |
I see there might be two problems with what you're doing.
1. Check your scrip has permission to run
Just chmod-it like
chmod +x /path/to/my/script.sh
chmod +x /path/to/ROC-smi/rocm-smi
Otherwise it won't run.
2. Fix wrong paths
When you have ./ROC-smi/rocm-smi
you're telling bash to run ROC-smi/rocm-smi
from the path you're calling the script, not from where the script is located. This means that if you call the script from /root
, bash will look for /root/ROC-smi/rocm-smi
and not for /path/to/my/script/ROC-smi/rocm-smi
.
The most straightforward solution is
#!/bin/bash
/absolute/path/to/ROC-smi/rocm-smi -d 1 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 0 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 2 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 3 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
However, if that script can run from anywhere, this quick patch will do as pointed out in this answer
#!/bin/bash
scriptdir="$(dirname "$0")"
cd $scriptdir"
ROC-smi/rocm-smi -d 1 --setfan 90
...
Now, $0
is unreliable (see here) so perhaps you want to try cd "${BASH_SOURCE%/*}"
instead. I would try
#!/bin/bash
cd ${BASH_SOURCE%/*}
ROC-smi/rocm-smi -d 1 --setfan 90
ROC-smi/rocm-smi -d 0 --setfan 90
ROC-smi/rocm-smi -d 2 --setfan 110
ROC-smi/rocm-smi -d 3 --setfan 110
ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
I see there might be two problems with what you're doing.
1. Check your scrip has permission to run
Just chmod-it like
chmod +x /path/to/my/script.sh
chmod +x /path/to/ROC-smi/rocm-smi
Otherwise it won't run.
2. Fix wrong paths
When you have ./ROC-smi/rocm-smi
you're telling bash to run ROC-smi/rocm-smi
from the path you're calling the script, not from where the script is located. This means that if you call the script from /root
, bash will look for /root/ROC-smi/rocm-smi
and not for /path/to/my/script/ROC-smi/rocm-smi
.
The most straightforward solution is
#!/bin/bash
/absolute/path/to/ROC-smi/rocm-smi -d 1 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 0 --setfan 90
/absolute/path/to/ROC-smi/rocm-smi -d 2 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 3 --setfan 110
/absolute/path/to/ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
However, if that script can run from anywhere, this quick patch will do as pointed out in this answer
#!/bin/bash
scriptdir="$(dirname "$0")"
cd $scriptdir"
ROC-smi/rocm-smi -d 1 --setfan 90
...
Now, $0
is unreliable (see here) so perhaps you want to try cd "${BASH_SOURCE%/*}"
instead. I would try
#!/bin/bash
cd ${BASH_SOURCE%/*}
ROC-smi/rocm-smi -d 1 --setfan 90
ROC-smi/rocm-smi -d 0 --setfan 90
ROC-smi/rocm-smi -d 2 --setfan 110
ROC-smi/rocm-smi -d 3 --setfan 110
ROC-smi/rocm-smi -d 4 --setfan 110
cd /absolute/path/to/teamredminer-v0.4.1-linux
/usr/bin/screen -dm ./teamredminer --algo=cnr --url=*** --user=*** --pass=*** --watchdog_script
answered Mar 22 at 16:22
KyordhelKyordhel
113
113
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIKrc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg../ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…
– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Letscript.sh
be#!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add@reboot /path/to/script.sh
. Reboot and check if works (it should). also checkgrep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
add a comment |
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIKrc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg../ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…
– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Letscript.sh
be#!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add@reboot /path/to/script.sh
. Reboot and check if works (it should). also checkgrep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
ok, both my scripts were working when im using them throught terminal. I fix all paths to absolute paths like you said, and still it dont work. When i tested it a got that message [ ok ] Starting rc.local (via systemctl): rc.local.service.
– mil0sz
Mar 22 at 17:12
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIK
rc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg. ./ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…– Kyordhel
Mar 22 at 17:26
Okay... Well, then it seems to be working pretty much OK once X server is up and running. AFAIK
rc.local
and cron may run before you have an X user session active, so maybe that's the hint. Can you eg. ./ROC-smi/rocm-smi -d 1 --setfan 90 | echo "1n" >> ./err.log
on each line just to verify the script is being invoked? If that's the case (running but crashing because X isn't ready), try with this answer askubuntu.com/questions/738640/…– Kyordhel
Mar 22 at 17:26
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Hmm, i added that on every line of my script with different numbers and i checked every directory where err.log shoud be created but I found nothing. I checked /etc; /ROC-smi, and teamredminer dir But i saw one thing when i run script manually. I got that error:
– mil0sz
Mar 22 at 18:45
Start with a MWE then. Let
script.sh
be #!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add @reboot /path/to/script.sh
. Reboot and check if works (it should). also check grep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
Start with a MWE then. Let
script.sh
be #!/bin/bashnecho "Chrontab did work $(date)n" >> /tmp/err.log
and then in crontab add @reboot /path/to/script.sh
. Reboot and check if works (it should). also check grep cron /var/log/syslog
– Kyordhel
Mar 22 at 20:22
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
ok, Thank you for your big help, decided to go more straighforward like in answer you sent me, i plug in monitor and manually from gui "Startup Applications" add command to run my script with absolute path and everything is working.
– mil0sz
Mar 23 at 7:17
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%2f1127873%2fhow-to-run-script-on-startup-with-root%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
2
Why do you want to start this as root? If you want a screen session that your user can use, you need it to be running as your user.
– terdon♦
Mar 22 at 15:33