Conveniently schedule a command to run later?












77















What's a simple way to run a command, say, 8 hours from now? I can think of this way:



nohup bash -c "sleep 28800 ; ./mycommand.sh" &


Is there a more "proper" way?










share|improve this question

























  • Is there something wrong with nohup + sleep? Why is it "improper"?

    – cprn
    Nov 24 '15 at 13:32
















77















What's a simple way to run a command, say, 8 hours from now? I can think of this way:



nohup bash -c "sleep 28800 ; ./mycommand.sh" &


Is there a more "proper" way?










share|improve this question

























  • Is there something wrong with nohup + sleep? Why is it "improper"?

    – cprn
    Nov 24 '15 at 13:32














77












77








77


31






What's a simple way to run a command, say, 8 hours from now? I can think of this way:



nohup bash -c "sleep 28800 ; ./mycommand.sh" &


Is there a more "proper" way?










share|improve this question
















What's a simple way to run a command, say, 8 hours from now? I can think of this way:



nohup bash -c "sleep 28800 ; ./mycommand.sh" &


Is there a more "proper" way?







bash command-line schedule






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 7 '13 at 11:51









Braiam

52.2k20137222




52.2k20137222










asked Aug 30 '13 at 11:25









Steve BennettSteve Bennett

1,10441322




1,10441322













  • Is there something wrong with nohup + sleep? Why is it "improper"?

    – cprn
    Nov 24 '15 at 13:32



















  • Is there something wrong with nohup + sleep? Why is it "improper"?

    – cprn
    Nov 24 '15 at 13:32

















Is there something wrong with nohup + sleep? Why is it "improper"?

– cprn
Nov 24 '15 at 13:32





Is there something wrong with nohup + sleep? Why is it "improper"?

– cprn
Nov 24 '15 at 13:32










4 Answers
4






active

oldest

votes


















112














You can use the at command. The at execute commands at a later time. The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.



Usually, at is installed by default in Ubuntu, but if your release doesn't include it, install via:



sudo apt-get install at


For more information, options, examples, and others see the Ubuntu Manpage Repository



Example:



at now +8 hours -f ~/myscript.sh


You can also use convenient shorthands, like tomorrow or noon, as in



echo "tweet fore" | at teatime 


Warning: This will run the command to the left of the pipe immediately but only present its output later.
The example also demonstrates how you can pipe actions into at. at -c is the way you can examine scheduled actions, which you can conveniently list with their number, as with:



at -c 3





share|improve this answer





















  • 17





    It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

    – steeldriver
    Aug 30 '13 at 12:12






  • 6





    In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

    – Simon Richter
    Aug 30 '13 at 18:09






  • 3





    In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

    – Dan
    Sep 6 '13 at 7:53








  • 3





    Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

    – heartsmagic
    Feb 12 '14 at 10:11








  • 4





    Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

    – Maciej Swic
    Feb 28 '17 at 8:38





















8














Yes, you can set a cron job.



For example if now the time is 14:39:00 and today is friday, 30 august, you can add the following cron job (to be executed after 8 hours) in your crontab file using crontab -e command:



39 22 30 8 5  /path/to/mycommand.sh


More about:




  • https://help.ubuntu.com/community/CronHowto

  • http://en.wikipedia.org/wiki/Cron






share|improve this answer





















  • 2





    Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

    – Steve Bennett
    Aug 30 '13 at 12:55






  • 3





    @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

    – Olivier Dulac
    Aug 30 '13 at 13:12






  • 2





    This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

    – emory
    Aug 30 '13 at 14:47






  • 1





    Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

    – Steve Bennett
    Sep 4 '13 at 1:20






  • 2





    @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

    – Paddy Landau
    Sep 4 '13 at 16:05



















7














Use the Gnome-based GUI for cron, at, and the like:



The introduction of the CronHowto suggests using the gnome-schedule gui, which is much nicer than typing all the garbage into the terminal (esp. for "average" Ubuntu users who are not "power" *nix/bsd users.)



Run it by using the Unity Dash (or other applications menu) to look for Scheduled Tasks or running gnome-schedule.




On Gnome-based Ubuntu systems Gnome Scheduled tasks tool (from the gnome-schedule
package) in Applications --> System Tools provides a graphical interface with prompting
for using Cron. The project website is at http://gnome-schedule.sourceforge.net/; the
software is installable from the Software Center or by typing



sudo apt-get install gnome-schedule


in a terminal.




Using gnome-schedule, for a script in your home directory, a new "at" command would be set up using this type of window:



enter image description here






share|improve this answer































    4














    I figured out a quick and dirty way to do this before I found out at was a thing.



    Say you want your script to run at noon:



    until [[ "$(date)" =~ "12:00:" ]]; do
    sleep 10
    done
    ./mycommand.sh


    Say you want it to run tomorrow at noon (today is Nov 24 for me):



    until [[ "$(date)" =~ "25 12:00:" ]]; do 
    sleep 30
    done
    ./mycommand.sh





    share|improve this answer





















    • 9





      To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

      – dimo414
      Jan 20 '17 at 8:39






    • 1





      @dimo414 What's wrong with my method?

      – wjandrea
      Jan 20 '17 at 17:20






    • 7





      At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

      – dimo414
      Jan 20 '17 at 17:36











    • (Aside: I didn't downvote your answer, I just don't think people should use it)

      – dimo414
      Jan 20 '17 at 17:37






    • 4





      Another reason to use at is because its jobs will survive a reboot.

      – manatwork
      Feb 28 '17 at 10:25











    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%2f339298%2fconveniently-schedule-a-command-to-run-later%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    112














    You can use the at command. The at execute commands at a later time. The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.



    Usually, at is installed by default in Ubuntu, but if your release doesn't include it, install via:



    sudo apt-get install at


    For more information, options, examples, and others see the Ubuntu Manpage Repository



    Example:



    at now +8 hours -f ~/myscript.sh


    You can also use convenient shorthands, like tomorrow or noon, as in



    echo "tweet fore" | at teatime 


    Warning: This will run the command to the left of the pipe immediately but only present its output later.
    The example also demonstrates how you can pipe actions into at. at -c is the way you can examine scheduled actions, which you can conveniently list with their number, as with:



    at -c 3





    share|improve this answer





















    • 17





      It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

      – steeldriver
      Aug 30 '13 at 12:12






    • 6





      In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

      – Simon Richter
      Aug 30 '13 at 18:09






    • 3





      In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

      – Dan
      Sep 6 '13 at 7:53








    • 3





      Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

      – heartsmagic
      Feb 12 '14 at 10:11








    • 4





      Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

      – Maciej Swic
      Feb 28 '17 at 8:38


















    112














    You can use the at command. The at execute commands at a later time. The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.



    Usually, at is installed by default in Ubuntu, but if your release doesn't include it, install via:



    sudo apt-get install at


    For more information, options, examples, and others see the Ubuntu Manpage Repository



    Example:



    at now +8 hours -f ~/myscript.sh


    You can also use convenient shorthands, like tomorrow or noon, as in



    echo "tweet fore" | at teatime 


    Warning: This will run the command to the left of the pipe immediately but only present its output later.
    The example also demonstrates how you can pipe actions into at. at -c is the way you can examine scheduled actions, which you can conveniently list with their number, as with:



    at -c 3





    share|improve this answer





















    • 17





      It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

      – steeldriver
      Aug 30 '13 at 12:12






    • 6





      In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

      – Simon Richter
      Aug 30 '13 at 18:09






    • 3





      In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

      – Dan
      Sep 6 '13 at 7:53








    • 3





      Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

      – heartsmagic
      Feb 12 '14 at 10:11








    • 4





      Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

      – Maciej Swic
      Feb 28 '17 at 8:38
















    112












    112








    112







    You can use the at command. The at execute commands at a later time. The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.



    Usually, at is installed by default in Ubuntu, but if your release doesn't include it, install via:



    sudo apt-get install at


    For more information, options, examples, and others see the Ubuntu Manpage Repository



    Example:



    at now +8 hours -f ~/myscript.sh


    You can also use convenient shorthands, like tomorrow or noon, as in



    echo "tweet fore" | at teatime 


    Warning: This will run the command to the left of the pipe immediately but only present its output later.
    The example also demonstrates how you can pipe actions into at. at -c is the way you can examine scheduled actions, which you can conveniently list with their number, as with:



    at -c 3





    share|improve this answer















    You can use the at command. The at execute commands at a later time. The at utility shall read commands from standard input and group them together as an at-job, to be executed at a later time.



    Usually, at is installed by default in Ubuntu, but if your release doesn't include it, install via:



    sudo apt-get install at


    For more information, options, examples, and others see the Ubuntu Manpage Repository



    Example:



    at now +8 hours -f ~/myscript.sh


    You can also use convenient shorthands, like tomorrow or noon, as in



    echo "tweet fore" | at teatime 


    Warning: This will run the command to the left of the pipe immediately but only present its output later.
    The example also demonstrates how you can pipe actions into at. at -c is the way you can examine scheduled actions, which you can conveniently list with their number, as with:



    at -c 3






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 28 '17 at 10:15









    Maciej Swic

    1032




    1032










    answered Aug 30 '13 at 11:39









    MitchMitch

    84.8k14173230




    84.8k14173230








    • 17





      It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

      – steeldriver
      Aug 30 '13 at 12:12






    • 6





      In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

      – Simon Richter
      Aug 30 '13 at 18:09






    • 3





      In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

      – Dan
      Sep 6 '13 at 7:53








    • 3





      Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

      – heartsmagic
      Feb 12 '14 at 10:11








    • 4





      Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

      – Maciej Swic
      Feb 28 '17 at 8:38
















    • 17





      It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

      – steeldriver
      Aug 30 '13 at 12:12






    • 6





      In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

      – Simon Richter
      Aug 30 '13 at 18:09






    • 3





      In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

      – Dan
      Sep 6 '13 at 7:53








    • 3





      Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

      – heartsmagic
      Feb 12 '14 at 10:11








    • 4





      Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

      – Maciej Swic
      Feb 28 '17 at 8:38










    17




    17





    It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

    – steeldriver
    Aug 30 '13 at 12:12





    It might be helpful to add a simple usage example that addresses the original poster's question more specifically e.g. at now +8 hours -f ~/myscript.sh

    – steeldriver
    Aug 30 '13 at 12:12




    6




    6





    In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

    – Simon Richter
    Aug 30 '13 at 18:09





    In addition, there is at 8:00 to run the command at an absolute time, and batch for "when it looks like the computer is idle"

    – Simon Richter
    Aug 30 '13 at 18:09




    3




    3





    In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

    – Dan
    Sep 6 '13 at 7:53







    In case anyone was wondering, teatime is at 4pm. For some reasons it's not mentioned in manpages.ubuntu.com/manpages/raring/man1/at.1posix.html but it is in man at and here manpages.ubuntu.com/manpages/raring/en/man1/at.1.html.

    – Dan
    Sep 6 '13 at 7:53






    3




    3





    Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

    – heartsmagic
    Feb 12 '14 at 10:11







    Maybe we can mention that "at" utility is not installed by default and if anyone else want to get it simply install the "at" package? Edit: Anyway, i simply edited the answer (also fixed the manpage link).

    – heartsmagic
    Feb 12 '14 at 10:11






    4




    4





    Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

    – Maciej Swic
    Feb 28 '17 at 8:38







    Beware that piping into at will run the command immediately and only schedule the output. I had a 4 hour 3D print fail because i wanted to schedule gpio write 8 1 but it executed right away.

    – Maciej Swic
    Feb 28 '17 at 8:38















    8














    Yes, you can set a cron job.



    For example if now the time is 14:39:00 and today is friday, 30 august, you can add the following cron job (to be executed after 8 hours) in your crontab file using crontab -e command:



    39 22 30 8 5  /path/to/mycommand.sh


    More about:




    • https://help.ubuntu.com/community/CronHowto

    • http://en.wikipedia.org/wiki/Cron






    share|improve this answer





















    • 2





      Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

      – Steve Bennett
      Aug 30 '13 at 12:55






    • 3





      @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

      – Olivier Dulac
      Aug 30 '13 at 13:12






    • 2





      This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

      – emory
      Aug 30 '13 at 14:47






    • 1





      Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

      – Steve Bennett
      Sep 4 '13 at 1:20






    • 2





      @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

      – Paddy Landau
      Sep 4 '13 at 16:05
















    8














    Yes, you can set a cron job.



    For example if now the time is 14:39:00 and today is friday, 30 august, you can add the following cron job (to be executed after 8 hours) in your crontab file using crontab -e command:



    39 22 30 8 5  /path/to/mycommand.sh


    More about:




    • https://help.ubuntu.com/community/CronHowto

    • http://en.wikipedia.org/wiki/Cron






    share|improve this answer





















    • 2





      Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

      – Steve Bennett
      Aug 30 '13 at 12:55






    • 3





      @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

      – Olivier Dulac
      Aug 30 '13 at 13:12






    • 2





      This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

      – emory
      Aug 30 '13 at 14:47






    • 1





      Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

      – Steve Bennett
      Sep 4 '13 at 1:20






    • 2





      @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

      – Paddy Landau
      Sep 4 '13 at 16:05














    8












    8








    8







    Yes, you can set a cron job.



    For example if now the time is 14:39:00 and today is friday, 30 august, you can add the following cron job (to be executed after 8 hours) in your crontab file using crontab -e command:



    39 22 30 8 5  /path/to/mycommand.sh


    More about:




    • https://help.ubuntu.com/community/CronHowto

    • http://en.wikipedia.org/wiki/Cron






    share|improve this answer















    Yes, you can set a cron job.



    For example if now the time is 14:39:00 and today is friday, 30 august, you can add the following cron job (to be executed after 8 hours) in your crontab file using crontab -e command:



    39 22 30 8 5  /path/to/mycommand.sh


    More about:




    • https://help.ubuntu.com/community/CronHowto

    • http://en.wikipedia.org/wiki/Cron







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 30 '13 at 11:50

























    answered Aug 30 '13 at 11:34









    Radu RădeanuRadu Rădeanu

    118k35251326




    118k35251326








    • 2





      Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

      – Steve Bennett
      Aug 30 '13 at 12:55






    • 3





      @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

      – Olivier Dulac
      Aug 30 '13 at 13:12






    • 2





      This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

      – emory
      Aug 30 '13 at 14:47






    • 1





      Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

      – Steve Bennett
      Sep 4 '13 at 1:20






    • 2





      @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

      – Paddy Landau
      Sep 4 '13 at 16:05














    • 2





      Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

      – Steve Bennett
      Aug 30 '13 at 12:55






    • 3





      @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

      – Olivier Dulac
      Aug 30 '13 at 13:12






    • 2





      This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

      – emory
      Aug 30 '13 at 14:47






    • 1





      Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

      – Steve Bennett
      Sep 4 '13 at 1:20






    • 2





      @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

      – Paddy Landau
      Sep 4 '13 at 16:05








    2




    2





    Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

    – Steve Bennett
    Aug 30 '13 at 12:55





    Ok, yes, I should have mentioned I know about Cron jobs. This is even messier because then it sits around in the crontab indefinitely, right?

    – Steve Bennett
    Aug 30 '13 at 12:55




    3




    3





    @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

    – Olivier Dulac
    Aug 30 '13 at 13:12





    @RaduRădeanu: with cron, careful that it could fire again in a few years (when there is another 30th of August occuring on a friday) ...

    – Olivier Dulac
    Aug 30 '13 at 13:12




    2




    2





    This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

    – emory
    Aug 30 '13 at 14:47





    This is a clever hack. However 'at' is a much better way. What would happen if the computer was turned off at 14:39?

    – emory
    Aug 30 '13 at 14:47




    1




    1





    Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

    – Steve Bennett
    Sep 4 '13 at 1:20





    Err that's still not my point. My point is that the text you entered will (I think) literally still be sitting in your crontab after the event, creating another cleanup task for you.

    – Steve Bennett
    Sep 4 '13 at 1:20




    2




    2





    @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

    – Paddy Landau
    Sep 4 '13 at 16:05





    @SteveBennett Yes, you are correct. The command will remain in your crontab until you remove it. A year later, when you have forgotten who put it there and why, you will be left scratching your head wondering what to do with the command.

    – Paddy Landau
    Sep 4 '13 at 16:05











    7














    Use the Gnome-based GUI for cron, at, and the like:



    The introduction of the CronHowto suggests using the gnome-schedule gui, which is much nicer than typing all the garbage into the terminal (esp. for "average" Ubuntu users who are not "power" *nix/bsd users.)



    Run it by using the Unity Dash (or other applications menu) to look for Scheduled Tasks or running gnome-schedule.




    On Gnome-based Ubuntu systems Gnome Scheduled tasks tool (from the gnome-schedule
    package) in Applications --> System Tools provides a graphical interface with prompting
    for using Cron. The project website is at http://gnome-schedule.sourceforge.net/; the
    software is installable from the Software Center or by typing



    sudo apt-get install gnome-schedule


    in a terminal.




    Using gnome-schedule, for a script in your home directory, a new "at" command would be set up using this type of window:



    enter image description here






    share|improve this answer




























      7














      Use the Gnome-based GUI for cron, at, and the like:



      The introduction of the CronHowto suggests using the gnome-schedule gui, which is much nicer than typing all the garbage into the terminal (esp. for "average" Ubuntu users who are not "power" *nix/bsd users.)



      Run it by using the Unity Dash (or other applications menu) to look for Scheduled Tasks or running gnome-schedule.




      On Gnome-based Ubuntu systems Gnome Scheduled tasks tool (from the gnome-schedule
      package) in Applications --> System Tools provides a graphical interface with prompting
      for using Cron. The project website is at http://gnome-schedule.sourceforge.net/; the
      software is installable from the Software Center or by typing



      sudo apt-get install gnome-schedule


      in a terminal.




      Using gnome-schedule, for a script in your home directory, a new "at" command would be set up using this type of window:



      enter image description here






      share|improve this answer


























        7












        7








        7







        Use the Gnome-based GUI for cron, at, and the like:



        The introduction of the CronHowto suggests using the gnome-schedule gui, which is much nicer than typing all the garbage into the terminal (esp. for "average" Ubuntu users who are not "power" *nix/bsd users.)



        Run it by using the Unity Dash (or other applications menu) to look for Scheduled Tasks or running gnome-schedule.




        On Gnome-based Ubuntu systems Gnome Scheduled tasks tool (from the gnome-schedule
        package) in Applications --> System Tools provides a graphical interface with prompting
        for using Cron. The project website is at http://gnome-schedule.sourceforge.net/; the
        software is installable from the Software Center or by typing



        sudo apt-get install gnome-schedule


        in a terminal.




        Using gnome-schedule, for a script in your home directory, a new "at" command would be set up using this type of window:



        enter image description here






        share|improve this answer













        Use the Gnome-based GUI for cron, at, and the like:



        The introduction of the CronHowto suggests using the gnome-schedule gui, which is much nicer than typing all the garbage into the terminal (esp. for "average" Ubuntu users who are not "power" *nix/bsd users.)



        Run it by using the Unity Dash (or other applications menu) to look for Scheduled Tasks or running gnome-schedule.




        On Gnome-based Ubuntu systems Gnome Scheduled tasks tool (from the gnome-schedule
        package) in Applications --> System Tools provides a graphical interface with prompting
        for using Cron. The project website is at http://gnome-schedule.sourceforge.net/; the
        software is installable from the Software Center or by typing



        sudo apt-get install gnome-schedule


        in a terminal.




        Using gnome-schedule, for a script in your home directory, a new "at" command would be set up using this type of window:



        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 16 '14 at 19:20









        user29020user29020

        318311




        318311























            4














            I figured out a quick and dirty way to do this before I found out at was a thing.



            Say you want your script to run at noon:



            until [[ "$(date)" =~ "12:00:" ]]; do
            sleep 10
            done
            ./mycommand.sh


            Say you want it to run tomorrow at noon (today is Nov 24 for me):



            until [[ "$(date)" =~ "25 12:00:" ]]; do 
            sleep 30
            done
            ./mycommand.sh





            share|improve this answer





















            • 9





              To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

              – dimo414
              Jan 20 '17 at 8:39






            • 1





              @dimo414 What's wrong with my method?

              – wjandrea
              Jan 20 '17 at 17:20






            • 7





              At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

              – dimo414
              Jan 20 '17 at 17:36











            • (Aside: I didn't downvote your answer, I just don't think people should use it)

              – dimo414
              Jan 20 '17 at 17:37






            • 4





              Another reason to use at is because its jobs will survive a reboot.

              – manatwork
              Feb 28 '17 at 10:25
















            4














            I figured out a quick and dirty way to do this before I found out at was a thing.



            Say you want your script to run at noon:



            until [[ "$(date)" =~ "12:00:" ]]; do
            sleep 10
            done
            ./mycommand.sh


            Say you want it to run tomorrow at noon (today is Nov 24 for me):



            until [[ "$(date)" =~ "25 12:00:" ]]; do 
            sleep 30
            done
            ./mycommand.sh





            share|improve this answer





















            • 9





              To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

              – dimo414
              Jan 20 '17 at 8:39






            • 1





              @dimo414 What's wrong with my method?

              – wjandrea
              Jan 20 '17 at 17:20






            • 7





              At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

              – dimo414
              Jan 20 '17 at 17:36











            • (Aside: I didn't downvote your answer, I just don't think people should use it)

              – dimo414
              Jan 20 '17 at 17:37






            • 4





              Another reason to use at is because its jobs will survive a reboot.

              – manatwork
              Feb 28 '17 at 10:25














            4












            4








            4







            I figured out a quick and dirty way to do this before I found out at was a thing.



            Say you want your script to run at noon:



            until [[ "$(date)" =~ "12:00:" ]]; do
            sleep 10
            done
            ./mycommand.sh


            Say you want it to run tomorrow at noon (today is Nov 24 for me):



            until [[ "$(date)" =~ "25 12:00:" ]]; do 
            sleep 30
            done
            ./mycommand.sh





            share|improve this answer















            I figured out a quick and dirty way to do this before I found out at was a thing.



            Say you want your script to run at noon:



            until [[ "$(date)" =~ "12:00:" ]]; do
            sleep 10
            done
            ./mycommand.sh


            Say you want it to run tomorrow at noon (today is Nov 24 for me):



            until [[ "$(date)" =~ "25 12:00:" ]]; do 
            sleep 30
            done
            ./mycommand.sh






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 5 '16 at 3:18

























            answered Nov 24 '15 at 6:07









            wjandreawjandrea

            9,28942664




            9,28942664








            • 9





              To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

              – dimo414
              Jan 20 '17 at 8:39






            • 1





              @dimo414 What's wrong with my method?

              – wjandrea
              Jan 20 '17 at 17:20






            • 7





              At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

              – dimo414
              Jan 20 '17 at 17:36











            • (Aside: I didn't downvote your answer, I just don't think people should use it)

              – dimo414
              Jan 20 '17 at 17:37






            • 4





              Another reason to use at is because its jobs will survive a reboot.

              – manatwork
              Feb 28 '17 at 10:25














            • 9





              To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

              – dimo414
              Jan 20 '17 at 8:39






            • 1





              @dimo414 What's wrong with my method?

              – wjandrea
              Jan 20 '17 at 17:20






            • 7





              At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

              – dimo414
              Jan 20 '17 at 17:36











            • (Aside: I didn't downvote your answer, I just don't think people should use it)

              – dimo414
              Jan 20 '17 at 17:37






            • 4





              Another reason to use at is because its jobs will survive a reboot.

              – manatwork
              Feb 28 '17 at 10:25








            9




            9





            To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

            – dimo414
            Jan 20 '17 at 8:39





            To the two people who've upvoted this answer, please use at, cron, or any other real scheduler application. Task scheduling is hard, and not a wheel you should reinvent.

            – dimo414
            Jan 20 '17 at 8:39




            1




            1





            @dimo414 What's wrong with my method?

            – wjandrea
            Jan 20 '17 at 17:20





            @dimo414 What's wrong with my method?

            – wjandrea
            Jan 20 '17 at 17:20




            7




            7





            At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

            – dimo414
            Jan 20 '17 at 17:36





            At a minimum, it's busy-waiting, which is wasteful. Worse, it's not guaranteed to be correct; it's perfectly possible (if unlikely) for the conditional to be missed. Basing your scheduler on regular expressions is also highly error-prone. It might work well-enough, but has no advantages over at.

            – dimo414
            Jan 20 '17 at 17:36













            (Aside: I didn't downvote your answer, I just don't think people should use it)

            – dimo414
            Jan 20 '17 at 17:37





            (Aside: I didn't downvote your answer, I just don't think people should use it)

            – dimo414
            Jan 20 '17 at 17:37




            4




            4





            Another reason to use at is because its jobs will survive a reboot.

            – manatwork
            Feb 28 '17 at 10:25





            Another reason to use at is because its jobs will survive a reboot.

            – manatwork
            Feb 28 '17 at 10:25


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f339298%2fconveniently-schedule-a-command-to-run-later%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

            日野市

            GameSpot

            Tu-95轟炸機