bash script not running at startup

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











up vote
0
down vote

favorite












I have created a simple bash script called echo.sh. Which outputs a string. I've made sure its executable. And i then added it to the "startup applications" program through the GUI interface. However when i reboot my machine, it doesn't appear to of been executed, as there is no echo appearing in a terminal.



from my understanding shouldn't the script ,when executed, open up a terminal automatically from my understanding because of the STDOUT being the terminal file. However the script works fine if i launch it myself from the terminal.



echo.sh



#!/bin/bash

echo "hello this is a bash script talking"


Making it Executable



chmod +x echo.sh


Adding to "startup applications with correct directory to file"
/home/sam/Documents/bash/echo.sh



Outcome



However when i reboot the system, the script doesn't run as expected, and no terminal appears with the echo message. I'm unsure as to why, and i may be completely missing the point, if so please let me know.



just to note, all my other bash scripts work , such as my "cleanup.sh" script which is also in the "startup applications" program.



Attempted fixes



I've tried redirecting the STDOUT to the terminal file /dev/tty. However this doesn't seem to work.



#!/bin/bash

echo "hello this is a bash script talking" >/dev/tty


I've also tested a bash script with just a simple rm command, just to check if it was just the echo command that was having a problem. However when added to start up applications or .bashrc file, it doesn't delete the test.txt in the same directory as the script. However works when i execute manually from the terminal.



#!/bin/bash

rm ./test.txt


I've also tested startup applications program itself with just opening Firefox, with just the command Firefox. Which works without an issue. So their doesn't seem to be an issue with the startup applications program itself?










share|improve this question























  • If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
    – mrc02_kr
    Jul 11 '17 at 12:55










  • Thanks for the response @mrc02_kr. However it doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:21










  • Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
    – mrc02_kr
    Jul 11 '17 at 13:37










  • Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
    – Hexodus
    Jul 11 '17 at 13:49










  • Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
    – mrc02_kr
    Jul 11 '17 at 13:56














up vote
0
down vote

favorite












I have created a simple bash script called echo.sh. Which outputs a string. I've made sure its executable. And i then added it to the "startup applications" program through the GUI interface. However when i reboot my machine, it doesn't appear to of been executed, as there is no echo appearing in a terminal.



from my understanding shouldn't the script ,when executed, open up a terminal automatically from my understanding because of the STDOUT being the terminal file. However the script works fine if i launch it myself from the terminal.



echo.sh



#!/bin/bash

echo "hello this is a bash script talking"


Making it Executable



chmod +x echo.sh


Adding to "startup applications with correct directory to file"
/home/sam/Documents/bash/echo.sh



Outcome



However when i reboot the system, the script doesn't run as expected, and no terminal appears with the echo message. I'm unsure as to why, and i may be completely missing the point, if so please let me know.



just to note, all my other bash scripts work , such as my "cleanup.sh" script which is also in the "startup applications" program.



Attempted fixes



I've tried redirecting the STDOUT to the terminal file /dev/tty. However this doesn't seem to work.



#!/bin/bash

echo "hello this is a bash script talking" >/dev/tty


I've also tested a bash script with just a simple rm command, just to check if it was just the echo command that was having a problem. However when added to start up applications or .bashrc file, it doesn't delete the test.txt in the same directory as the script. However works when i execute manually from the terminal.



#!/bin/bash

rm ./test.txt


I've also tested startup applications program itself with just opening Firefox, with just the command Firefox. Which works without an issue. So their doesn't seem to be an issue with the startup applications program itself?










share|improve this question























  • If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
    – mrc02_kr
    Jul 11 '17 at 12:55










  • Thanks for the response @mrc02_kr. However it doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:21










  • Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
    – mrc02_kr
    Jul 11 '17 at 13:37










  • Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
    – Hexodus
    Jul 11 '17 at 13:49










  • Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
    – mrc02_kr
    Jul 11 '17 at 13:56












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have created a simple bash script called echo.sh. Which outputs a string. I've made sure its executable. And i then added it to the "startup applications" program through the GUI interface. However when i reboot my machine, it doesn't appear to of been executed, as there is no echo appearing in a terminal.



from my understanding shouldn't the script ,when executed, open up a terminal automatically from my understanding because of the STDOUT being the terminal file. However the script works fine if i launch it myself from the terminal.



echo.sh



#!/bin/bash

echo "hello this is a bash script talking"


Making it Executable



chmod +x echo.sh


Adding to "startup applications with correct directory to file"
/home/sam/Documents/bash/echo.sh



Outcome



However when i reboot the system, the script doesn't run as expected, and no terminal appears with the echo message. I'm unsure as to why, and i may be completely missing the point, if so please let me know.



just to note, all my other bash scripts work , such as my "cleanup.sh" script which is also in the "startup applications" program.



Attempted fixes



I've tried redirecting the STDOUT to the terminal file /dev/tty. However this doesn't seem to work.



#!/bin/bash

echo "hello this is a bash script talking" >/dev/tty


I've also tested a bash script with just a simple rm command, just to check if it was just the echo command that was having a problem. However when added to start up applications or .bashrc file, it doesn't delete the test.txt in the same directory as the script. However works when i execute manually from the terminal.



#!/bin/bash

rm ./test.txt


I've also tested startup applications program itself with just opening Firefox, with just the command Firefox. Which works without an issue. So their doesn't seem to be an issue with the startup applications program itself?










share|improve this question















I have created a simple bash script called echo.sh. Which outputs a string. I've made sure its executable. And i then added it to the "startup applications" program through the GUI interface. However when i reboot my machine, it doesn't appear to of been executed, as there is no echo appearing in a terminal.



from my understanding shouldn't the script ,when executed, open up a terminal automatically from my understanding because of the STDOUT being the terminal file. However the script works fine if i launch it myself from the terminal.



echo.sh



#!/bin/bash

echo "hello this is a bash script talking"


Making it Executable



chmod +x echo.sh


Adding to "startup applications with correct directory to file"
/home/sam/Documents/bash/echo.sh



Outcome



However when i reboot the system, the script doesn't run as expected, and no terminal appears with the echo message. I'm unsure as to why, and i may be completely missing the point, if so please let me know.



just to note, all my other bash scripts work , such as my "cleanup.sh" script which is also in the "startup applications" program.



Attempted fixes



I've tried redirecting the STDOUT to the terminal file /dev/tty. However this doesn't seem to work.



#!/bin/bash

echo "hello this is a bash script talking" >/dev/tty


I've also tested a bash script with just a simple rm command, just to check if it was just the echo command that was having a problem. However when added to start up applications or .bashrc file, it doesn't delete the test.txt in the same directory as the script. However works when i execute manually from the terminal.



#!/bin/bash

rm ./test.txt


I've also tested startup applications program itself with just opening Firefox, with just the command Firefox. Which works without an issue. So their doesn't seem to be an issue with the startup applications program itself?







bash ubuntu






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 11 '17 at 13:35

























asked Jul 11 '17 at 12:43









Hexodus

11




11











  • If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
    – mrc02_kr
    Jul 11 '17 at 12:55










  • Thanks for the response @mrc02_kr. However it doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:21










  • Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
    – mrc02_kr
    Jul 11 '17 at 13:37










  • Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
    – Hexodus
    Jul 11 '17 at 13:49










  • Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
    – mrc02_kr
    Jul 11 '17 at 13:56
















  • If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
    – mrc02_kr
    Jul 11 '17 at 12:55










  • Thanks for the response @mrc02_kr. However it doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:21










  • Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
    – mrc02_kr
    Jul 11 '17 at 13:37










  • Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
    – Hexodus
    Jul 11 '17 at 13:49










  • Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
    – mrc02_kr
    Jul 11 '17 at 13:56















If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
– mrc02_kr
Jul 11 '17 at 12:55




If you want to run this script during starting terminal add it to .bashrc file. Probably it runs at startup but you cannot see the output. You can check dmesg log, but I'm not sure if it's going to be there
– mrc02_kr
Jul 11 '17 at 12:55












Thanks for the response @mrc02_kr. However it doesn't seem to work.
– Hexodus
Jul 11 '17 at 13:21




Thanks for the response @mrc02_kr. However it doesn't seem to work.
– Hexodus
Jul 11 '17 at 13:21












Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
– mrc02_kr
Jul 11 '17 at 13:37




Try to avoid using relative paths in scripts. It leads to unexpected behavior and then a lot of debugging. Try to redirect echo to file: echo "bash script" > /root/test_bash.txt. Also tell us what do you want to achive ? Maybe it's a better way to do it?
– mrc02_kr
Jul 11 '17 at 13:37












Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
– Hexodus
Jul 11 '17 at 13:49




Well my initial script, which called "sudo apt-get update" has similar issues. So i decided to try and start up a simple echo script. Which doesn't work. Which is really confusing as my cleanup.sh script works perfectly at boot up.
– Hexodus
Jul 11 '17 at 13:49












Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
– mrc02_kr
Jul 11 '17 at 13:56




Don't run apt-get update at startup. Here is tutorial how to automate apt updates.
– mrc02_kr
Jul 11 '17 at 13:56










1 Answer
1






active

oldest

votes

















up vote
0
down vote













The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to



#!/bin/bash
gnome-terminal -e 'echo "hello this is a bash script talking"'


(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)






share|improve this answer




















  • Thanks for the response, However this doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:11










  • What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
    – rien333
    Jul 11 '17 at 13:28










  • Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
    – Hexodus
    Jul 11 '17 at 13:37






  • 1




    @Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
    – Pandya
    Jul 11 '17 at 17:44










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f377702%2fbash-script-not-running-at-startup%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to



#!/bin/bash
gnome-terminal -e 'echo "hello this is a bash script talking"'


(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)






share|improve this answer




















  • Thanks for the response, However this doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:11










  • What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
    – rien333
    Jul 11 '17 at 13:28










  • Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
    – Hexodus
    Jul 11 '17 at 13:37






  • 1




    @Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
    – Pandya
    Jul 11 '17 at 17:44














up vote
0
down vote













The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to



#!/bin/bash
gnome-terminal -e 'echo "hello this is a bash script talking"'


(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)






share|improve this answer




















  • Thanks for the response, However this doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:11










  • What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
    – rien333
    Jul 11 '17 at 13:28










  • Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
    – Hexodus
    Jul 11 '17 at 13:37






  • 1




    @Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
    – Pandya
    Jul 11 '17 at 17:44












up vote
0
down vote










up vote
0
down vote









The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to



#!/bin/bash
gnome-terminal -e 'echo "hello this is a bash script talking"'


(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)






share|improve this answer












The script probably works, but the STDOUT of the script (wherever the output is directed to) is connected to the process on your OS that is concerned with launching startup scripts like this, which does not run in a terminal, but is a user hidden process within for example the kernel. To open up a terminal with this message you should probably edit it to



#!/bin/bash
gnome-terminal -e 'echo "hello this is a bash script talking"'


(I'm not on Ubuntu right now so can't test this, but the gist is to explicitly open a terminal where you want this message to show up in)







share|improve this answer












share|improve this answer



share|improve this answer










answered Jul 11 '17 at 12:50









rien333

203113




203113











  • Thanks for the response, However this doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:11










  • What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
    – rien333
    Jul 11 '17 at 13:28










  • Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
    – Hexodus
    Jul 11 '17 at 13:37






  • 1




    @Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
    – Pandya
    Jul 11 '17 at 17:44
















  • Thanks for the response, However this doesn't seem to work.
    – Hexodus
    Jul 11 '17 at 13:11










  • What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
    – rien333
    Jul 11 '17 at 13:28










  • Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
    – Hexodus
    Jul 11 '17 at 13:37






  • 1




    @Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
    – Pandya
    Jul 11 '17 at 17:44















Thanks for the response, However this doesn't seem to work.
– Hexodus
Jul 11 '17 at 13:11




Thanks for the response, However this doesn't seem to work.
– Hexodus
Jul 11 '17 at 13:11












What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
– rien333
Jul 11 '17 at 13:28




What happens when you enter gnome-terminal -e 'echo "hello this is a bash script talking"' in a terminal?
– rien333
Jul 11 '17 at 13:28












Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
– Hexodus
Jul 11 '17 at 13:37




Executing it manually, it flashed opened up a window and quickly closed. Not sure if it was a terminal, however from the quick flash of an application appearing, it didn't look like a terminal. When added to the startup applications and rebooted,nothing occurred.
– Hexodus
Jul 11 '17 at 13:37




1




1




@Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
– Pandya
Jul 11 '17 at 17:44




@Hexodus I suggest gnome-terminal -x bash -c 'echo "hello this is a bash script talking";bash' so-that you can examine.
– Pandya
Jul 11 '17 at 17:44

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f377702%2fbash-script-not-running-at-startup%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay