Run the script file after 5 or 10 min after restarting the system
I have created a ruby script file that checks the connection present or not. For example checking port 22 is opened or not.
Firstly I tried with cron job as follows
@reboot find ${HOME}/my_app/check_conn.rb
But it is executing immediately after starting the system.
Now I have to run this script after 5 or 10 min.
How can I do this. Is there any other way for doing this.
Thanks in advance.
cron scripts
add a comment |
I have created a ruby script file that checks the connection present or not. For example checking port 22 is opened or not.
Firstly I tried with cron job as follows
@reboot find ${HOME}/my_app/check_conn.rb
But it is executing immediately after starting the system.
Now I have to run this script after 5 or 10 min.
How can I do this. Is there any other way for doing this.
Thanks in advance.
cron scripts
2
A bad hack: Addsleep 600;
to the beginning of the command.
– dan08
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put anat
command inside that file to execute it 5 minutes from now?
– Rinzwind
Jul 2 '14 at 16:31
@dan08 did I have to addsleep 600;
before my cron_job or in my script file?
– user2622247
Jul 3 '14 at 7:31
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45
add a comment |
I have created a ruby script file that checks the connection present or not. For example checking port 22 is opened or not.
Firstly I tried with cron job as follows
@reboot find ${HOME}/my_app/check_conn.rb
But it is executing immediately after starting the system.
Now I have to run this script after 5 or 10 min.
How can I do this. Is there any other way for doing this.
Thanks in advance.
cron scripts
I have created a ruby script file that checks the connection present or not. For example checking port 22 is opened or not.
Firstly I tried with cron job as follows
@reboot find ${HOME}/my_app/check_conn.rb
But it is executing immediately after starting the system.
Now I have to run this script after 5 or 10 min.
How can I do this. Is there any other way for doing this.
Thanks in advance.
cron scripts
cron scripts
edited Jul 3 '14 at 7:26
user2622247
asked Jul 2 '14 at 16:26
user2622247user2622247
2502415
2502415
2
A bad hack: Addsleep 600;
to the beginning of the command.
– dan08
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put anat
command inside that file to execute it 5 minutes from now?
– Rinzwind
Jul 2 '14 at 16:31
@dan08 did I have to addsleep 600;
before my cron_job or in my script file?
– user2622247
Jul 3 '14 at 7:31
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45
add a comment |
2
A bad hack: Addsleep 600;
to the beginning of the command.
– dan08
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put anat
command inside that file to execute it 5 minutes from now?
– Rinzwind
Jul 2 '14 at 16:31
@dan08 did I have to addsleep 600;
before my cron_job or in my script file?
– user2622247
Jul 3 '14 at 7:31
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45
2
2
A bad hack: Add
sleep 600;
to the beginning of the command.– dan08
Jul 2 '14 at 16:31
A bad hack: Add
sleep 600;
to the beginning of the command.– dan08
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put an
at
command inside that file to execute it 5 minutes from now?– Rinzwind
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put an
at
command inside that file to execute it 5 minutes from now?– Rinzwind
Jul 2 '14 at 16:31
@dan08 did I have to add
sleep 600;
before my cron_job or in my script file?– user2622247
Jul 3 '14 at 7:31
@dan08 did I have to add
sleep 600;
before my cron_job or in my script file?– user2622247
Jul 3 '14 at 7:31
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45
add a comment |
2 Answers
2
active
oldest
votes
Add sleep 600;
to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.
Your new crontab command would look like
@reboot sleep 600; find ${HOME}/my_app/check_conn.rb
add a comment |
Don't do it depending on time, but after establishing a network connection. The right place to do it is below:
/etc/network/if-up.d
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%2f490881%2frun-the-script-file-after-5-or-10-min-after-restarting-the-system%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
Add sleep 600;
to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.
Your new crontab command would look like
@reboot sleep 600; find ${HOME}/my_app/check_conn.rb
add a comment |
Add sleep 600;
to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.
Your new crontab command would look like
@reboot sleep 600; find ${HOME}/my_app/check_conn.rb
add a comment |
Add sleep 600;
to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.
Your new crontab command would look like
@reboot sleep 600; find ${HOME}/my_app/check_conn.rb
Add sleep 600;
to the beginning of your crontab command to make it wait for 600 seconds before proceeding to the next step.
Your new crontab command would look like
@reboot sleep 600; find ${HOME}/my_app/check_conn.rb
edited Jul 3 '14 at 12:37
answered Jul 3 '14 at 12:27
dan08dan08
5,16721840
5,16721840
add a comment |
add a comment |
Don't do it depending on time, but after establishing a network connection. The right place to do it is below:
/etc/network/if-up.d
add a comment |
Don't do it depending on time, but after establishing a network connection. The right place to do it is below:
/etc/network/if-up.d
add a comment |
Don't do it depending on time, but after establishing a network connection. The right place to do it is below:
/etc/network/if-up.d
Don't do it depending on time, but after establishing a network connection. The right place to do it is below:
/etc/network/if-up.d
answered Jan 15 '18 at 17:03
user unknownuser unknown
4,87122151
4,87122151
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f490881%2frun-the-script-file-after-5-or-10-min-after-restarting-the-system%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
2
A bad hack: Add
sleep 600;
to the beginning of the command.– dan08
Jul 2 '14 at 16:31
I would never execute from cron itself and always create an executable file in /etc/cronjob; Just put an
at
command inside that file to execute it 5 minutes from now?– Rinzwind
Jul 2 '14 at 16:31
@dan08 did I have to add
sleep 600;
before my cron_job or in my script file?– user2622247
Jul 3 '14 at 7:31
@dan08, please post your comment as an answer.
– Andrejs Cainikovs
Jul 3 '14 at 7:45