1

I have a script file that I would like to run whenever my computer starts up. What the script file does is run a .jar file that I have on my desktop.

I first created a .jar file called Hello.jar that is located on my desktop. After that I created a script file (.sh) called Script.sh that has the following contents in it.

cd Desktop;java -jar Hello.jar;

Then I followed this answer to run the file on startup. So as it says I first setup a .desktop file by running this command in the terminal.

sudo cd Desktop
sudo mv Script.sh /usr/bin

Then I did

sudo cd /usr/share/applications
sudo gedit file.desktop & 

Then I wrote the following information in gedit.

[Desktop Entry]
Name=Hello.sh
Exec=/usr/bin/file.sh
Type=Application
Terminal=false

And lastly I created a copy of it in this location.

/etc/xdg/autostart/

I then restarted my computer but nothing happened.

Community
  • 1
  • 1
user2612619
  • 1,119
  • 3
  • 11
  • 28

1 Answers1

0

sudo cd doesn't do anything! The cd command only takes effect within the current shell - which immediately exits!

Instead you should do sudo bash to launch a root shell. Then run all your commands within that root shell.

Also, I think you forgot to give your script execute permissions. You can do that by changing mv to install.

Robin Green
  • 32,079
  • 16
  • 104
  • 187