Executing .jar File on Startup
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Hello this is a question pertaining to my Raspberry Pi but since it is a general Linux question, I posted here instead.
I'm running a Nukkit Minecraft server on my Raspberry Pi (I know it doesn't have good hardware but I'm experimenting) and googling different ways to make a bash file for Linux. I have made the file startNukkit.whateverextension. I have come to this:
!#/bin/bash/
gnome-terminal -e "java -jar home/pi/Desktop/Nukkit/nukkit.jar; exec bash""
But there are multiple things I want to solve. First, when I double click the bash file it will prompt me to: "Execute", "Execute in Terminal", "Open", and "Cancel". Instead, I would like to run it right away without this prompt.
And because this is a Minecraft server, I can only see the results of the server in the terminal, such as who connects to my server. But if I click on "Execute in Terminal", the terminal will show and then close. I thought this could be solved by "exec bash"" as explained here. To keep the terminal window open.
And finally, I would like to make this execute in startup similar to how in Windows has a startup folder where any file you place in this folder will execute in startup.
If you found that this is a duplicate question of a similar post. Please notify me before downvoting or deleting this post. I have made this post only because I want all these questions answered as one to help those who are googling the same thing. Thank you! And sorry for the disclaimer!
shell-script startup
add a comment |Â
up vote
1
down vote
favorite
Hello this is a question pertaining to my Raspberry Pi but since it is a general Linux question, I posted here instead.
I'm running a Nukkit Minecraft server on my Raspberry Pi (I know it doesn't have good hardware but I'm experimenting) and googling different ways to make a bash file for Linux. I have made the file startNukkit.whateverextension. I have come to this:
!#/bin/bash/
gnome-terminal -e "java -jar home/pi/Desktop/Nukkit/nukkit.jar; exec bash""
But there are multiple things I want to solve. First, when I double click the bash file it will prompt me to: "Execute", "Execute in Terminal", "Open", and "Cancel". Instead, I would like to run it right away without this prompt.
And because this is a Minecraft server, I can only see the results of the server in the terminal, such as who connects to my server. But if I click on "Execute in Terminal", the terminal will show and then close. I thought this could be solved by "exec bash"" as explained here. To keep the terminal window open.
And finally, I would like to make this execute in startup similar to how in Windows has a startup folder where any file you place in this folder will execute in startup.
If you found that this is a duplicate question of a similar post. Please notify me before downvoting or deleting this post. I have made this post only because I want all these questions answered as one to help those who are googling the same thing. Thank you! And sorry for the disclaimer!
shell-script startup
2
It should be#!
, not!#
.
â G-Man
Nov 11 '17 at 15:29
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
You can put your command in/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.
â Arpit Agarwal
Nov 11 '17 at 16:04
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Hello this is a question pertaining to my Raspberry Pi but since it is a general Linux question, I posted here instead.
I'm running a Nukkit Minecraft server on my Raspberry Pi (I know it doesn't have good hardware but I'm experimenting) and googling different ways to make a bash file for Linux. I have made the file startNukkit.whateverextension. I have come to this:
!#/bin/bash/
gnome-terminal -e "java -jar home/pi/Desktop/Nukkit/nukkit.jar; exec bash""
But there are multiple things I want to solve. First, when I double click the bash file it will prompt me to: "Execute", "Execute in Terminal", "Open", and "Cancel". Instead, I would like to run it right away without this prompt.
And because this is a Minecraft server, I can only see the results of the server in the terminal, such as who connects to my server. But if I click on "Execute in Terminal", the terminal will show and then close. I thought this could be solved by "exec bash"" as explained here. To keep the terminal window open.
And finally, I would like to make this execute in startup similar to how in Windows has a startup folder where any file you place in this folder will execute in startup.
If you found that this is a duplicate question of a similar post. Please notify me before downvoting or deleting this post. I have made this post only because I want all these questions answered as one to help those who are googling the same thing. Thank you! And sorry for the disclaimer!
shell-script startup
Hello this is a question pertaining to my Raspberry Pi but since it is a general Linux question, I posted here instead.
I'm running a Nukkit Minecraft server on my Raspberry Pi (I know it doesn't have good hardware but I'm experimenting) and googling different ways to make a bash file for Linux. I have made the file startNukkit.whateverextension. I have come to this:
!#/bin/bash/
gnome-terminal -e "java -jar home/pi/Desktop/Nukkit/nukkit.jar; exec bash""
But there are multiple things I want to solve. First, when I double click the bash file it will prompt me to: "Execute", "Execute in Terminal", "Open", and "Cancel". Instead, I would like to run it right away without this prompt.
And because this is a Minecraft server, I can only see the results of the server in the terminal, such as who connects to my server. But if I click on "Execute in Terminal", the terminal will show and then close. I thought this could be solved by "exec bash"" as explained here. To keep the terminal window open.
And finally, I would like to make this execute in startup similar to how in Windows has a startup folder where any file you place in this folder will execute in startup.
If you found that this is a duplicate question of a similar post. Please notify me before downvoting or deleting this post. I have made this post only because I want all these questions answered as one to help those who are googling the same thing. Thank you! And sorry for the disclaimer!
shell-script startup
asked Nov 11 '17 at 15:17
Mr. El
63
63
2
It should be#!
, not!#
.
â G-Man
Nov 11 '17 at 15:29
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
You can put your command in/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.
â Arpit Agarwal
Nov 11 '17 at 16:04
add a comment |Â
2
It should be#!
, not!#
.
â G-Man
Nov 11 '17 at 15:29
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
You can put your command in/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.
â Arpit Agarwal
Nov 11 '17 at 16:04
2
2
It should be
#!
, not !#
.â G-Man
Nov 11 '17 at 15:29
It should be
#!
, not !#
.â G-Man
Nov 11 '17 at 15:29
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
You can put your command in
/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.â Arpit Agarwal
Nov 11 '17 at 16:04
You can put your command in
/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.â Arpit Agarwal
Nov 11 '17 at 16:04
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
As a systemd
service
(You didn't mention a specific GNU/Linux distribution, I think most common ones have systemd available though)
If you move your .jar file to some accessible place like /opt
then you could have systemd
run your server after startup as nobody
or some other low-privilege user.
In addition to potentially running without access to home directories, etc. you can also configure systemd to restart a service after failure and many other things.
See man systemd.service
, man systemd.exec
, man systemd.unit
, etc.
nukkit.service
[Unit]
Description=Nukkit Server
After=syslog.target
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=java -jar /opt/Nukkit/nukkit.jar
[Install]
WantedBy=multi-user.target
Watching output
Where you have /etc/systemd/system/nukkit.service
and have:
systemctl enable nukkit
systemctl start nukkit
then journalctl -f -u nukkit
should f
ollow the most recent log messages from systemd u
nit nukkit. Your system may be using syslog or some other facility though; in that case you could configure logging to a specific file, etc.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
As a systemd
service
(You didn't mention a specific GNU/Linux distribution, I think most common ones have systemd available though)
If you move your .jar file to some accessible place like /opt
then you could have systemd
run your server after startup as nobody
or some other low-privilege user.
In addition to potentially running without access to home directories, etc. you can also configure systemd to restart a service after failure and many other things.
See man systemd.service
, man systemd.exec
, man systemd.unit
, etc.
nukkit.service
[Unit]
Description=Nukkit Server
After=syslog.target
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=java -jar /opt/Nukkit/nukkit.jar
[Install]
WantedBy=multi-user.target
Watching output
Where you have /etc/systemd/system/nukkit.service
and have:
systemctl enable nukkit
systemctl start nukkit
then journalctl -f -u nukkit
should f
ollow the most recent log messages from systemd u
nit nukkit. Your system may be using syslog or some other facility though; in that case you could configure logging to a specific file, etc.
add a comment |Â
up vote
1
down vote
As a systemd
service
(You didn't mention a specific GNU/Linux distribution, I think most common ones have systemd available though)
If you move your .jar file to some accessible place like /opt
then you could have systemd
run your server after startup as nobody
or some other low-privilege user.
In addition to potentially running without access to home directories, etc. you can also configure systemd to restart a service after failure and many other things.
See man systemd.service
, man systemd.exec
, man systemd.unit
, etc.
nukkit.service
[Unit]
Description=Nukkit Server
After=syslog.target
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=java -jar /opt/Nukkit/nukkit.jar
[Install]
WantedBy=multi-user.target
Watching output
Where you have /etc/systemd/system/nukkit.service
and have:
systemctl enable nukkit
systemctl start nukkit
then journalctl -f -u nukkit
should f
ollow the most recent log messages from systemd u
nit nukkit. Your system may be using syslog or some other facility though; in that case you could configure logging to a specific file, etc.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
As a systemd
service
(You didn't mention a specific GNU/Linux distribution, I think most common ones have systemd available though)
If you move your .jar file to some accessible place like /opt
then you could have systemd
run your server after startup as nobody
or some other low-privilege user.
In addition to potentially running without access to home directories, etc. you can also configure systemd to restart a service after failure and many other things.
See man systemd.service
, man systemd.exec
, man systemd.unit
, etc.
nukkit.service
[Unit]
Description=Nukkit Server
After=syslog.target
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=java -jar /opt/Nukkit/nukkit.jar
[Install]
WantedBy=multi-user.target
Watching output
Where you have /etc/systemd/system/nukkit.service
and have:
systemctl enable nukkit
systemctl start nukkit
then journalctl -f -u nukkit
should f
ollow the most recent log messages from systemd u
nit nukkit. Your system may be using syslog or some other facility though; in that case you could configure logging to a specific file, etc.
As a systemd
service
(You didn't mention a specific GNU/Linux distribution, I think most common ones have systemd available though)
If you move your .jar file to some accessible place like /opt
then you could have systemd
run your server after startup as nobody
or some other low-privilege user.
In addition to potentially running without access to home directories, etc. you can also configure systemd to restart a service after failure and many other things.
See man systemd.service
, man systemd.exec
, man systemd.unit
, etc.
nukkit.service
[Unit]
Description=Nukkit Server
After=syslog.target
After=network.target
[Service]
Type=simple
User=nobody
Group=nobody
ExecStart=java -jar /opt/Nukkit/nukkit.jar
[Install]
WantedBy=multi-user.target
Watching output
Where you have /etc/systemd/system/nukkit.service
and have:
systemctl enable nukkit
systemctl start nukkit
then journalctl -f -u nukkit
should f
ollow the most recent log messages from systemd u
nit nukkit. Your system may be using syslog or some other facility though; in that case you could configure logging to a specific file, etc.
answered Nov 12 '17 at 1:20
Andrew Siplas
1815
1815
add a comment |Â
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f403915%2fexecuting-jar-file-on-startup%23new-answer', 'question_page');
);
Post as a guest
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
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
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
2
It should be
#!
, not!#
.â G-Man
Nov 11 '17 at 15:29
My apologies I didn't notice! But when I go to make the change the terminal window is blank. What else am I doing wrong?
â Mr. El
Nov 11 '17 at 15:30
You can put your command in
/home/pi/.config/lxsession/LXDE-pi/autostart
file. Commands in this script are executed on every boot.â Arpit Agarwal
Nov 11 '17 at 16:04