Cron task won't run, although all is correctly set up Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Results Why I closed the “Why is Kali so hard” questionTracking huge buffer usage under LinuxSend cron mails to root bundled every hourEntries in /etc/crontab not getting called in Centos 6.xcrontab not launching one scriptcrontab: “Temporary crontab no longer owned by you.”Why would /etc/crontab set HOME=/ in environment?Is it possible to write to the crontab from a multipurpose script?Is there a common way of auto-updates with cron?Why is crond failing to run a non-root crontab on alpine linux?Cron log shows shell script has run but it really hasn't

Am I ethically obligated to go into work on an off day if the reason is sudden?

What's the point in a preamp?

Stars Make Stars

Can't figure this one out.. What is the missing box?

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Windows 10: How to Lock (not sleep) laptop on lid close?

Stop battery usage [Ubuntu 18]

Writing Thesis: Copying from published papers

Was credit for the black hole image misattributed?

How to add zeros to reach same number of decimal places in tables?

How does modal jazz use chord progressions?

Can I throw a sword that doesn't have the Thrown property at someone?

Strange behaviour of Check

What's the difference between (size_t)-1 and ~0?

Keep going mode for require-package

How many spell slots should a Fighter 11/Ranger 9 have?

Complexity of many constant time steps with occasional logarithmic steps

Estimate capacitor parameters

What is the largest species of polychaete?

Estimated State payment too big --> money back; + 2018 Tax Reform

Need a suitable toxic chemical for a murder plot in my novel

Aligning matrix of nodes with grid

When is phishing education going too far?

Did the new image of black hole confirm the general theory of relativity?



Cron task won't run, although all is correctly set up



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionTracking huge buffer usage under LinuxSend cron mails to root bundled every hourEntries in /etc/crontab not getting called in Centos 6.xcrontab not launching one scriptcrontab: “Temporary crontab no longer owned by you.”Why would /etc/crontab set HOME=/ in environment?Is it possible to write to the crontab from a multipurpose script?Is there a common way of auto-updates with cron?Why is crond failing to run a non-root crontab on alpine linux?Cron log shows shell script has run but it really hasn't



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















This cron tqsk doesn't work:



[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1

[main_usr@localhost ~]$


And



$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh


As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.



Why?










share|improve this question

















  • 1





    Has root received any email from the cron daemon containing errors?

    – Kusalananda
    Apr 10 at 20:08






  • 2





    What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

    – hymie
    Apr 10 at 20:08











  • Do other cron jobs work? If not, is the cron service running?

    – K7AAY
    Apr 10 at 20:35

















0















This cron tqsk doesn't work:



[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1

[main_usr@localhost ~]$


And



$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh


As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.



Why?










share|improve this question

















  • 1





    Has root received any email from the cron daemon containing errors?

    – Kusalananda
    Apr 10 at 20:08






  • 2





    What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

    – hymie
    Apr 10 at 20:08











  • Do other cron jobs work? If not, is the cron service running?

    – K7AAY
    Apr 10 at 20:35













0












0








0








This cron tqsk doesn't work:



[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1

[main_usr@localhost ~]$


And



$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh


As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.



Why?










share|improve this question














This cron tqsk doesn't work:



[main_usr@localhost ~]$ sudo crontab -l -u root
0 * * * * /home/main_usr/cron_test1.sh > /home/main_usr/cron_test1_out.sh.out 2>&1

[main_usr@localhost ~]$


And



$ ls -al cron_test1.sh
-rwxr-xr-x 1 main_usr main_usr 293 Apr 8 05:12 cron_test1.sh


As you can see, there's a new line in the cron tasks. And the file exists and is executable. The task was created a day ago. It should've run once in an hour. Nonetheless, 'cron_test1_out.sh.out' hasn't been created.



Why?







linux cron






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 10 at 20:05









jijinojijino

11




11







  • 1





    Has root received any email from the cron daemon containing errors?

    – Kusalananda
    Apr 10 at 20:08






  • 2





    What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

    – hymie
    Apr 10 at 20:08











  • Do other cron jobs work? If not, is the cron service running?

    – K7AAY
    Apr 10 at 20:35












  • 1





    Has root received any email from the cron daemon containing errors?

    – Kusalananda
    Apr 10 at 20:08






  • 2





    What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

    – hymie
    Apr 10 at 20:08











  • Do other cron jobs work? If not, is the cron service running?

    – K7AAY
    Apr 10 at 20:35







1




1





Has root received any email from the cron daemon containing errors?

– Kusalananda
Apr 10 at 20:08





Has root received any email from the cron daemon containing errors?

– Kusalananda
Apr 10 at 20:08




2




2





What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

– hymie
Apr 10 at 20:08





What does your script look like? Does your script run from the command line? If so, what output does it normally produce? is the cron daemon running?

– hymie
Apr 10 at 20:08













Do other cron jobs work? If not, is the cron service running?

– K7AAY
Apr 10 at 20:35





Do other cron jobs work? If not, is the cron service running?

– K7AAY
Apr 10 at 20:35










2 Answers
2






active

oldest

votes


















0














Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as



PATH=/usr/bin:/bin:/usr/local/bin





share|improve this answer








New contributor




Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.



























    0














    I had the same issue some time ago.



    Adding /bin/bash fixed it for me.



    Example:



    0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory



    Reason:
    When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.



    Cron itself does not know where to run the script.



    Please also check /var/log/syslog and /var/mail/root to see the reason.






    share|improve this answer










    New contributor




    Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2funix.stackexchange.com%2fquestions%2f511751%2fcron-task-wont-run-although-all-is-correctly-set-up%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









      0














      Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as



      PATH=/usr/bin:/bin:/usr/local/bin





      share|improve this answer








      New contributor




      Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























        0














        Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as



        PATH=/usr/bin:/bin:/usr/local/bin





        share|improve this answer








        New contributor




        Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















          0












          0








          0







          Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as



          PATH=/usr/bin:/bin:/usr/local/bin





          share|improve this answer








          New contributor




          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          Cron tasks are run with /bin/sh and a blank environment, so sometimes you may need to source your bash profile or some other environment file, or optionally, include the environment variables in the cron file. PATH is usually the biggest offender. By default, path is set to /usr/bin:/bin, so if your script refers to any executables that are not in these two directories without the full path, your cron will fail. You can set any of the environment variable in the crontab with a simple KEY=VALUE, such as



          PATH=/usr/bin:/bin:/usr/local/bin






          share|improve this answer








          New contributor




          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer






          New contributor




          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered Apr 10 at 21:19









          Mike BreedMike Breed

          1




          1




          New contributor




          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Mike Breed is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.























              0














              I had the same issue some time ago.



              Adding /bin/bash fixed it for me.



              Example:



              0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory



              Reason:
              When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.



              Cron itself does not know where to run the script.



              Please also check /var/log/syslog and /var/mail/root to see the reason.






              share|improve this answer










              New contributor




              Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.
























                0














                I had the same issue some time ago.



                Adding /bin/bash fixed it for me.



                Example:



                0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory



                Reason:
                When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.



                Cron itself does not know where to run the script.



                Please also check /var/log/syslog and /var/mail/root to see the reason.






                share|improve this answer










                New contributor




                Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                  0












                  0








                  0







                  I had the same issue some time ago.



                  Adding /bin/bash fixed it for me.



                  Example:



                  0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory



                  Reason:
                  When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.



                  Cron itself does not know where to run the script.



                  Please also check /var/log/syslog and /var/mail/root to see the reason.






                  share|improve this answer










                  New contributor




                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.










                  I had the same issue some time ago.



                  Adding /bin/bash fixed it for me.



                  Example:



                  0 * * * * /bin/bash /path_to_your_script/script.sh > /output_directory



                  Reason:
                  When running a shell script you have to define where the script should be executed, so probably you have to use /bin/sh, /bin/zsh or what ever to run the script within.



                  Cron itself does not know where to run the script.



                  Please also check /var/log/syslog and /var/mail/root to see the reason.







                  share|improve this answer










                  New contributor




                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  share|improve this answer



                  share|improve this answer








                  edited Apr 10 at 21:22





















                  New contributor




                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.









                  answered Apr 10 at 21:03









                  SchnarchnaseSchnarchnase

                  11




                  11




                  New contributor




                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.





                  New contributor





                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.






                  Schnarchnase is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                  Check out our Code of Conduct.



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • 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%2funix.stackexchange.com%2fquestions%2f511751%2fcron-task-wont-run-although-all-is-correctly-set-up%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

                      getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                      Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                      Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.