0

I have created one myscript.sh file as following

#!/bin/bash  
source ~/.profile  
cd $GOPATH/src  
revel run test/streetcom  

I need to run this file at startup after login.
I tried using startup application by creating a new field with command as the path of myscript.sh which is:

/home/pi/myscript.sh

but it did not work. I want to run the above script on the terminal after login on startup. Is there any way to run this script on tmux session. I tried adding following line after #!/bin/ bash in myscript.sh file.

tmux new -s piwork 

Tmux session piwork got created but the remaining commands getting executed in another terminal window.

0

if you want to run the script at startup, do the following :

  1. Run sudo chmod +x /home/pi/myscript.sh to make your script executable.
  2. Open .bashrc file using sudo gedit ~/.bashrc or sudo nano ~/.bashrc
  3. Place the command that runs the script (./home/pi/myscript.sh) in the end of the file.
  4. Save and exit.

It should run on the next startup.

  • it is ./pi/home/myscript.sh Also, check the bath to your script, is it /pi/home/myscript or /home/pi/myscript? – singrium May 23 '18 at 9:16
  • Do you want it to run automatically after startup or what exactly? I am a bit confused now. – singrium May 23 '18 at 9:20
  • 1
    Firstly, one # in the beginning is enough. Second, there is no need to write sh before ./pi/home/myscript.sh – Josef Klimuk May 23 '18 at 9:38
  • Yes, I want to run it after startup. But the thing is when my pi boots up it doesnt show anthing after login on the display. But after login into SSH session the script work just fine. Is there any way to run these commands on the terminal after login. – Logan May 23 '18 at 10:05
  • 1
    The problem can be in the disabling login & password windows. You can check it by trying to run some 'echo "hello world", if it will also not run automatically - try to turn off disabling the password. – Josef Klimuk May 23 '18 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.