Run the script file after 5 or 10 min after restarting the system












3














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.










share|improve this question




















  • 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
















3














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.










share|improve this question




















  • 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














3












3








3


1





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.










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 3 '14 at 7:26







user2622247

















asked Jul 2 '14 at 16:26









user2622247user2622247

2502415




2502415








  • 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














  • 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








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










2 Answers
2






active

oldest

votes


















5














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






share|improve this answer































    0














    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





    share|improve this answer





















      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      5














      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






      share|improve this answer




























        5














        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






        share|improve this answer


























          5












          5








          5






          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






          share|improve this answer














          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







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 3 '14 at 12:37

























          answered Jul 3 '14 at 12:27









          dan08dan08

          5,16721840




          5,16721840

























              0














              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





              share|improve this answer


























                0














                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





                share|improve this answer
























                  0












                  0








                  0






                  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





                  share|improve this answer












                  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






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 15 '18 at 17:03









                  user unknownuser unknown

                  4,87122151




                  4,87122151






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                      Mangá

                       ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕