How to write a startup script
I want to write a startup script file, that start my kafka environment.
I tried as following:
#!/bin/bash
/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
The problem is, it starts only the zookeeper but not kafka server.
What am I doing wrong?
scripts
add a comment |
I want to write a startup script file, that start my kafka environment.
I tried as following:
#!/bin/bash
/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
The problem is, it starts only the zookeeper but not kafka server.
What am I doing wrong?
scripts
add a comment |
I want to write a startup script file, that start my kafka environment.
I tried as following:
#!/bin/bash
/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
The problem is, it starts only the zookeeper but not kafka server.
What am I doing wrong?
scripts
I want to write a startup script file, that start my kafka environment.
I tried as following:
#!/bin/bash
/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
The problem is, it starts only the zookeeper but not kafka server.
What am I doing wrong?
scripts
scripts
asked Nov 28 '17 at 10:45
zero_codingzero_coding
1781212
1781212
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Assuming that this script doesn't need sudo privileges.
One way to autostart a script is use a Desktop Autostarting method.
In Ubuntu you can do it like this,
- Create a file in .config/autostart from your home directory with an extension of .desktop
Say you created zookeeper.desktop then open and include this format.
For Zookeeper Entry
[Desktop Entry]
Type=Application
Name=Zookeeper
Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
Then create a separate one for:
For Kafra Entry
[Desktop Entry]
Type=Application
Name=kafra
Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
or just the script your made
For your Script Entry
[Desktop Entry]
Type=Application
Name=/name/of/your/script
Exec=/path/to/your/script
Then you can do it like this(sudo)
add the path of your script to /etc/rc.local(open and edit rc.local)
/path/to/your/script &
exit 0
if it doesn't exist but it your system have /etc/rc.d1 to 6
just simply add your script inside that folder and will be executed with sudo rights.
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
add a comment |
A variant of the approach described above is to modify the Exec command in the .desktop file as follows:
Exec=gnome-terminal -- /path/to/your/script.sh start
This has two advantages
- You can store your script anywhere you like without having to modify anything in rc.local or /etc
- You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.
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%2f981047%2fhow-to-write-a-startup-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Assuming that this script doesn't need sudo privileges.
One way to autostart a script is use a Desktop Autostarting method.
In Ubuntu you can do it like this,
- Create a file in .config/autostart from your home directory with an extension of .desktop
Say you created zookeeper.desktop then open and include this format.
For Zookeeper Entry
[Desktop Entry]
Type=Application
Name=Zookeeper
Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
Then create a separate one for:
For Kafra Entry
[Desktop Entry]
Type=Application
Name=kafra
Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
or just the script your made
For your Script Entry
[Desktop Entry]
Type=Application
Name=/name/of/your/script
Exec=/path/to/your/script
Then you can do it like this(sudo)
add the path of your script to /etc/rc.local(open and edit rc.local)
/path/to/your/script &
exit 0
if it doesn't exist but it your system have /etc/rc.d1 to 6
just simply add your script inside that folder and will be executed with sudo rights.
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
add a comment |
Assuming that this script doesn't need sudo privileges.
One way to autostart a script is use a Desktop Autostarting method.
In Ubuntu you can do it like this,
- Create a file in .config/autostart from your home directory with an extension of .desktop
Say you created zookeeper.desktop then open and include this format.
For Zookeeper Entry
[Desktop Entry]
Type=Application
Name=Zookeeper
Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
Then create a separate one for:
For Kafra Entry
[Desktop Entry]
Type=Application
Name=kafra
Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
or just the script your made
For your Script Entry
[Desktop Entry]
Type=Application
Name=/name/of/your/script
Exec=/path/to/your/script
Then you can do it like this(sudo)
add the path of your script to /etc/rc.local(open and edit rc.local)
/path/to/your/script &
exit 0
if it doesn't exist but it your system have /etc/rc.d1 to 6
just simply add your script inside that folder and will be executed with sudo rights.
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
add a comment |
Assuming that this script doesn't need sudo privileges.
One way to autostart a script is use a Desktop Autostarting method.
In Ubuntu you can do it like this,
- Create a file in .config/autostart from your home directory with an extension of .desktop
Say you created zookeeper.desktop then open and include this format.
For Zookeeper Entry
[Desktop Entry]
Type=Application
Name=Zookeeper
Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
Then create a separate one for:
For Kafra Entry
[Desktop Entry]
Type=Application
Name=kafra
Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
or just the script your made
For your Script Entry
[Desktop Entry]
Type=Application
Name=/name/of/your/script
Exec=/path/to/your/script
Then you can do it like this(sudo)
add the path of your script to /etc/rc.local(open and edit rc.local)
/path/to/your/script &
exit 0
if it doesn't exist but it your system have /etc/rc.d1 to 6
just simply add your script inside that folder and will be executed with sudo rights.
Assuming that this script doesn't need sudo privileges.
One way to autostart a script is use a Desktop Autostarting method.
In Ubuntu you can do it like this,
- Create a file in .config/autostart from your home directory with an extension of .desktop
Say you created zookeeper.desktop then open and include this format.
For Zookeeper Entry
[Desktop Entry]
Type=Application
Name=Zookeeper
Exec=/usr/local/zookeeper-3.4.11/bin/zkServer.sh start
Then create a separate one for:
For Kafra Entry
[Desktop Entry]
Type=Application
Name=kafra
Exec=/usr/local/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /usr/local/kafka_2.12-1.0.0/config/server.properties
or just the script your made
For your Script Entry
[Desktop Entry]
Type=Application
Name=/name/of/your/script
Exec=/path/to/your/script
Then you can do it like this(sudo)
add the path of your script to /etc/rc.local(open and edit rc.local)
/path/to/your/script &
exit 0
if it doesn't exist but it your system have /etc/rc.d1 to 6
just simply add your script inside that folder and will be executed with sudo rights.
edited Nov 29 '17 at 9:03
answered Nov 29 '17 at 6:05
YienYien
1546
1546
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
add a comment |
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
I've forgot to mentioned. The script needs sudo privileges.
– zero_coding
Nov 29 '17 at 8:28
Edited, just now
– Yien
Nov 29 '17 at 9:10
Edited, just now
– Yien
Nov 29 '17 at 9:10
add a comment |
A variant of the approach described above is to modify the Exec command in the .desktop file as follows:
Exec=gnome-terminal -- /path/to/your/script.sh start
This has two advantages
- You can store your script anywhere you like without having to modify anything in rc.local or /etc
- You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.
add a comment |
A variant of the approach described above is to modify the Exec command in the .desktop file as follows:
Exec=gnome-terminal -- /path/to/your/script.sh start
This has two advantages
- You can store your script anywhere you like without having to modify anything in rc.local or /etc
- You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.
add a comment |
A variant of the approach described above is to modify the Exec command in the .desktop file as follows:
Exec=gnome-terminal -- /path/to/your/script.sh start
This has two advantages
- You can store your script anywhere you like without having to modify anything in rc.local or /etc
- You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.
A variant of the approach described above is to modify the Exec command in the .desktop file as follows:
Exec=gnome-terminal -- /path/to/your/script.sh start
This has two advantages
- You can store your script anywhere you like without having to modify anything in rc.local or /etc
- You launch the script within a new terminal window which allows you to see the prompt of the script and e.g. type in a required sudo password in case your script contains a sudo command.
answered Jan 16 at 10:53
Turbo ReynoldsTurbo Reynolds
11
11
add a comment |
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%2f981047%2fhow-to-write-a-startup-script%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