How can I execute `date` inside of a cron tab job?2019 Community Moderator ElectionAdding timestamp into log file via cronjob commandMplayer cronjob doesn't workUsage of '%' in the crontabHow can I pass a filename containing percent signs (%) as a parameter to a shell script in cron?Using date variable with wget --post-dataCrontab /bin/sh syntaxShell script not running in crontabWhat is causing my “Unexpected EOF Error while looking for …” error?Cron Job every 55 minutescron logging but not working on some commandsWhy can't cron job find basic Linux commands?Cron job does not fire up after a timezone changecron runs job at unexpected timeswhy daily cron isn't running on CentOS 6?Getting cron to include date in error logCron tab to run a java fileCron job isn't writing to log fileWhy does my cron job not work?Cron job not running on libreelecPython script runs as bash command on terminal but not as a cron job

Why can't the Brexit deadlock in the UK parliament be solved with a plurality vote?

Is it allowed to activate the ability of multiple planeswalkers in a single turn?

What is Cash Advance APR?

Is my low blitz game drawing rate at www.chess.com an indicator that I am weak in chess?

Does "he squandered his car on drink" sound natural?

When were female captains banned from Starfleet?

What (the heck) is a Super Worm Equinox Moon?

How could a planet have erratic days?

The IT department bottlenecks progress, how should I handle this?

I found an audio circuit and I built it just fine, but I find it a bit too quiet. How do I amplify the output so that it is a bit louder?

Does an advisor owe his/her student anything? Will an advisor keep a PhD student only out of pity?

C++ copy constructor called at return

Why should universal income be universal?

Why Shazam when there is already Superman?

Is there any evidence that Cleopatra and Caesarion considered fleeing to India to escape the Romans?

How do I fix the group tension caused by my character stealing and possibly killing without provocation?

Microchip documentation does not label CAN buss pins on micro controller pinout diagram

Can I say "fingers" when referring to toes?

What does "Scientists rise up against statistical significance" mean? (Comment in Nature)

Doesn't the system of the Supreme Court oppose justice?

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

Taxes on Dividends in a Roth IRA

Why do ¬, ∀ and ∃ have the same precedence?

Shouldn’t conservatives embrace universal basic income?



How can I execute `date` inside of a cron tab job?



2019 Community Moderator ElectionAdding timestamp into log file via cronjob commandMplayer cronjob doesn't workUsage of '%' in the crontabHow can I pass a filename containing percent signs (%) as a parameter to a shell script in cron?Using date variable with wget --post-dataCrontab /bin/sh syntaxShell script not running in crontabWhat is causing my “Unexpected EOF Error while looking for …” error?Cron Job every 55 minutescron logging but not working on some commandsWhy can't cron job find basic Linux commands?Cron job does not fire up after a timezone changecron runs job at unexpected timeswhy daily cron isn't running on CentOS 6?Getting cron to include date in error logCron tab to run a java fileCron job isn't writing to log fileWhy does my cron job not work?Cron job not running on libreelecPython script runs as bash command on terminal but not as a cron job










98















I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:



0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


Unfortunately I get this message when that runs:



/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file


I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?










share|improve this question




























    98















    I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:



    0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


    Unfortunately I get this message when that runs:



    /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
    /bin/sh: -c: line 1: syntax error: unexpected end of file


    I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?










    share|improve this question


























      98












      98








      98


      23






      I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:



      0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


      Unfortunately I get this message when that runs:



      /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
      /bin/sh: -c: line 1: syntax error: unexpected end of file


      I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?










      share|improve this question
















      I want to create a log file for a cron script that has the current hour in the log file name. This is the command I tried to use:



      0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


      Unfortunately I get this message when that runs:



      /bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
      /bin/sh: -c: line 1: syntax error: unexpected end of file


      I have tried escaping the date part in various ways, but without much luck. Is it possible to make this happen in-line in a crontab file or do I need to create a shell script to do this?







      cron quoting command-substitution






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 20 '12 at 23:00









      Gilles

      543k12811001618




      543k12811001618










      asked Jan 20 '12 at 17:12









      cwdcwd

      14.1k53116157




      14.1k53116157




















          5 Answers
          5






          active

          oldest

          votes


















          153














          Short answer:



          Escape the % as %:



          0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


          Long answer:



          The error message suggests that the shell which executes your command doesn't see the second back tick character:



          /bin/sh: -c: line 0: unexpected EOF while looking for matching '`'


          This is also confirmed by the second error message your received when you tried one of the other answers:



          /bin/sh: -c: line 0: unexpected EOF while looking for matching ')'


          The crontab manpage confirms that the command is read only up to the first unescaped % sign:




          The "sixth" field (the rest of the line) specifies the command to
          be run. The entire command portion of the line, up to a newline or
          % character, will be executed by /bin/sh or by the shell specified in
          the SHELL variable of the cronfile. Percent-signs (%) in the
          command, unless escaped with backslash (), will be changed into
          newline characters, and all data after the first % will be sent to
          the command as standard input.







          share|improve this answer

























          • Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

            – Tebe
            May 20 '15 at 6:24






          • 2





            @Копать_Шо_я_нашел cron will send an email with the error message,

            – Jasen
            Jan 1 '16 at 6:50






          • 3





            date +%Y %m %d %H:%M:%S-cronlog

            – DevilCode
            Apr 4 '16 at 13:36


















          7














          You can also put your commands into a shell file and then execute the shell file with cron.



          jobs.sh



          echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


          cron



          0 * * * * sh jobs.sh





          share|improve this answer






























            6














            If you would like to make the date formatting string as a variable (to avoid duplicating the whole string), DO NOT escape % and DO NOT put it in $()



            For example, while declare the string, just write:



            DATEVAR=date +%Y%m%d_%H%M%S


            Then, write cron statement with $($VARIABLE_NAME) like this:



            * * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log


            Thanks to cyberx86, her/his answer at ServerFault might be more completed:






            share|improve this answer
































              2














              In cron, you can use this simple syntax:



              */15 01-09 * * * sh /script.sh >> /home/username/cron_$(date -d"-0 days" +%Y%m%d).log 2>&1





              share|improve this answer

























              • Output date format will retrun like cron_20180123.log

                – bala4rtraining
                Jan 24 '18 at 13:51











              • (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                – G-Man
                Dec 23 '18 at 6:27


















              2














              All of the above answers use double quotes (not all of them worked for my setup). This worked for me:



              0 5 * * 3 /data/script.sh > /data/script_`date +%y%m%d`.log 2>&1





              share|improve this answer




















              • 1





                What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                – G-Man
                Dec 23 '18 at 6:27











              • The accepted answer simply doesn't work for me. This one does.

                – Manuel Schmitzberger
                Dec 23 '18 at 8:44










              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%2f29578%2fhow-can-i-execute-date-inside-of-a-cron-tab-job%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              153














              Short answer:



              Escape the % as %:



              0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


              Long answer:



              The error message suggests that the shell which executes your command doesn't see the second back tick character:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching '`'


              This is also confirmed by the second error message your received when you tried one of the other answers:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching ')'


              The crontab manpage confirms that the command is read only up to the first unescaped % sign:




              The "sixth" field (the rest of the line) specifies the command to
              be run. The entire command portion of the line, up to a newline or
              % character, will be executed by /bin/sh or by the shell specified in
              the SHELL variable of the cronfile. Percent-signs (%) in the
              command, unless escaped with backslash (), will be changed into
              newline characters, and all data after the first % will be sent to
              the command as standard input.







              share|improve this answer

























              • Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

                – Tebe
                May 20 '15 at 6:24






              • 2





                @Копать_Шо_я_нашел cron will send an email with the error message,

                – Jasen
                Jan 1 '16 at 6:50






              • 3





                date +%Y %m %d %H:%M:%S-cronlog

                – DevilCode
                Apr 4 '16 at 13:36















              153














              Short answer:



              Escape the % as %:



              0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


              Long answer:



              The error message suggests that the shell which executes your command doesn't see the second back tick character:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching '`'


              This is also confirmed by the second error message your received when you tried one of the other answers:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching ')'


              The crontab manpage confirms that the command is read only up to the first unescaped % sign:




              The "sixth" field (the rest of the line) specifies the command to
              be run. The entire command portion of the line, up to a newline or
              % character, will be executed by /bin/sh or by the shell specified in
              the SHELL variable of the cronfile. Percent-signs (%) in the
              command, unless escaped with backslash (), will be changed into
              newline characters, and all data after the first % will be sent to
              the command as standard input.







              share|improve this answer

























              • Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

                – Tebe
                May 20 '15 at 6:24






              • 2





                @Копать_Шо_я_нашел cron will send an email with the error message,

                – Jasen
                Jan 1 '16 at 6:50






              • 3





                date +%Y %m %d %H:%M:%S-cronlog

                – DevilCode
                Apr 4 '16 at 13:36













              153












              153








              153







              Short answer:



              Escape the % as %:



              0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


              Long answer:



              The error message suggests that the shell which executes your command doesn't see the second back tick character:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching '`'


              This is also confirmed by the second error message your received when you tried one of the other answers:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching ')'


              The crontab manpage confirms that the command is read only up to the first unescaped % sign:




              The "sixth" field (the rest of the line) specifies the command to
              be run. The entire command portion of the line, up to a newline or
              % character, will be executed by /bin/sh or by the shell specified in
              the SHELL variable of the cronfile. Percent-signs (%) in the
              command, unless escaped with backslash (), will be changed into
              newline characters, and all data after the first % will be sent to
              the command as standard input.







              share|improve this answer















              Short answer:



              Escape the % as %:



              0 * * * * echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


              Long answer:



              The error message suggests that the shell which executes your command doesn't see the second back tick character:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching '`'


              This is also confirmed by the second error message your received when you tried one of the other answers:



              /bin/sh: -c: line 0: unexpected EOF while looking for matching ')'


              The crontab manpage confirms that the command is read only up to the first unescaped % sign:




              The "sixth" field (the rest of the line) specifies the command to
              be run. The entire command portion of the line, up to a newline or
              % character, will be executed by /bin/sh or by the shell specified in
              the SHELL variable of the cronfile. Percent-signs (%) in the
              command, unless escaped with backslash (), will be changed into
              newline characters, and all data after the first % will be sent to
              the command as standard input.








              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited yesterday









              Kusalananda

              137k17258426




              137k17258426










              answered Jan 20 '12 at 17:31









              Adam ZalcmanAdam Zalcman

              2,69611513




              2,69611513












              • Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

                – Tebe
                May 20 '15 at 6:24






              • 2





                @Копать_Шо_я_нашел cron will send an email with the error message,

                – Jasen
                Jan 1 '16 at 6:50






              • 3





                date +%Y %m %d %H:%M:%S-cronlog

                – DevilCode
                Apr 4 '16 at 13:36

















              • Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

                – Tebe
                May 20 '15 at 6:24






              • 2





                @Копать_Шо_я_нашел cron will send an email with the error message,

                – Jasen
                Jan 1 '16 at 6:50






              • 3





                date +%Y %m %d %H:%M:%S-cronlog

                – DevilCode
                Apr 4 '16 at 13:36
















              Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

              – Tebe
              May 20 '15 at 6:24





              Sorry for my ignorance, but where do you see this error messages? When I do 'grep CRON /var/log/syslog' I see no error messages, although cron failed - kagda.ru/i/9a016249a39_20-05-2015-09:22:47_9a01.png

              – Tebe
              May 20 '15 at 6:24




              2




              2





              @Копать_Шо_я_нашел cron will send an email with the error message,

              – Jasen
              Jan 1 '16 at 6:50





              @Копать_Шо_я_нашел cron will send an email with the error message,

              – Jasen
              Jan 1 '16 at 6:50




              3




              3





              date +%Y %m %d %H:%M:%S-cronlog

              – DevilCode
              Apr 4 '16 at 13:36





              date +%Y %m %d %H:%M:%S-cronlog

              – DevilCode
              Apr 4 '16 at 13:36













              7














              You can also put your commands into a shell file and then execute the shell file with cron.



              jobs.sh



              echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


              cron



              0 * * * * sh jobs.sh





              share|improve this answer



























                7














                You can also put your commands into a shell file and then execute the shell file with cron.



                jobs.sh



                echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


                cron



                0 * * * * sh jobs.sh





                share|improve this answer

























                  7












                  7








                  7







                  You can also put your commands into a shell file and then execute the shell file with cron.



                  jobs.sh



                  echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


                  cron



                  0 * * * * sh jobs.sh





                  share|improve this answer













                  You can also put your commands into a shell file and then execute the shell file with cron.



                  jobs.sh



                  echo hello >> ~/cron-logs/hourly/test`date "+%d"`.log


                  cron



                  0 * * * * sh jobs.sh






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 3 '15 at 14:41









                  Trevi AwaterTrevi Awater

                  17315




                  17315





















                      6














                      If you would like to make the date formatting string as a variable (to avoid duplicating the whole string), DO NOT escape % and DO NOT put it in $()



                      For example, while declare the string, just write:



                      DATEVAR=date +%Y%m%d_%H%M%S


                      Then, write cron statement with $($VARIABLE_NAME) like this:



                      * * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log


                      Thanks to cyberx86, her/his answer at ServerFault might be more completed:






                      share|improve this answer





























                        6














                        If you would like to make the date formatting string as a variable (to avoid duplicating the whole string), DO NOT escape % and DO NOT put it in $()



                        For example, while declare the string, just write:



                        DATEVAR=date +%Y%m%d_%H%M%S


                        Then, write cron statement with $($VARIABLE_NAME) like this:



                        * * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log


                        Thanks to cyberx86, her/his answer at ServerFault might be more completed:






                        share|improve this answer



























                          6












                          6








                          6







                          If you would like to make the date formatting string as a variable (to avoid duplicating the whole string), DO NOT escape % and DO NOT put it in $()



                          For example, while declare the string, just write:



                          DATEVAR=date +%Y%m%d_%H%M%S


                          Then, write cron statement with $($VARIABLE_NAME) like this:



                          * * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log


                          Thanks to cyberx86, her/his answer at ServerFault might be more completed:






                          share|improve this answer















                          If you would like to make the date formatting string as a variable (to avoid duplicating the whole string), DO NOT escape % and DO NOT put it in $()



                          For example, while declare the string, just write:



                          DATEVAR=date +%Y%m%d_%H%M%S


                          Then, write cron statement with $($VARIABLE_NAME) like this:



                          * * * * * /bin/echo $($DATEVAR) >> /tmp/crontab.log


                          Thanks to cyberx86, her/his answer at ServerFault might be more completed:







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Aug 10 '17 at 10:24









                          Stéphane Chazelas

                          311k57586945




                          311k57586945










                          answered Jan 4 '16 at 8:41









                          Gawi - KaiGawi - Kai

                          6114




                          6114





















                              2














                              In cron, you can use this simple syntax:



                              */15 01-09 * * * sh /script.sh >> /home/username/cron_$(date -d"-0 days" +%Y%m%d).log 2>&1





                              share|improve this answer

























                              • Output date format will retrun like cron_20180123.log

                                – bala4rtraining
                                Jan 24 '18 at 13:51











                              • (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                                – G-Man
                                Dec 23 '18 at 6:27















                              2














                              In cron, you can use this simple syntax:



                              */15 01-09 * * * sh /script.sh >> /home/username/cron_$(date -d"-0 days" +%Y%m%d).log 2>&1





                              share|improve this answer

























                              • Output date format will retrun like cron_20180123.log

                                – bala4rtraining
                                Jan 24 '18 at 13:51











                              • (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                                – G-Man
                                Dec 23 '18 at 6:27













                              2












                              2








                              2







                              In cron, you can use this simple syntax:



                              */15 01-09 * * * sh /script.sh >> /home/username/cron_$(date -d"-0 days" +%Y%m%d).log 2>&1





                              share|improve this answer















                              In cron, you can use this simple syntax:



                              */15 01-09 * * * sh /script.sh >> /home/username/cron_$(date -d"-0 days" +%Y%m%d).log 2>&1






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 24 '18 at 14:41









                              Kevin Lemaire

                              1,184724




                              1,184724










                              answered Jan 24 '18 at 13:50









                              bala4rtrainingbala4rtraining

                              312




                              312












                              • Output date format will retrun like cron_20180123.log

                                – bala4rtraining
                                Jan 24 '18 at 13:51











                              • (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                                – G-Man
                                Dec 23 '18 at 6:27

















                              • Output date format will retrun like cron_20180123.log

                                – bala4rtraining
                                Jan 24 '18 at 13:51











                              • (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                                – G-Man
                                Dec 23 '18 at 6:27
















                              Output date format will retrun like cron_20180123.log

                              – bala4rtraining
                              Jan 24 '18 at 13:51





                              Output date format will retrun like cron_20180123.log

                              – bala4rtraining
                              Jan 24 '18 at 13:51













                              (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                              – G-Man
                              Dec 23 '18 at 6:27





                              (1) What are you saying that hasn’t already been said by the accepted answer?   (2) Your answer is much more complicated than the question.  For example, you added the -d option, which is not used in the question (and you did not explain it).  How do you justify calling this “simple syntax”?

                              – G-Man
                              Dec 23 '18 at 6:27











                              2














                              All of the above answers use double quotes (not all of them worked for my setup). This worked for me:



                              0 5 * * 3 /data/script.sh > /data/script_`date +%y%m%d`.log 2>&1





                              share|improve this answer




















                              • 1





                                What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                                – G-Man
                                Dec 23 '18 at 6:27











                              • The accepted answer simply doesn't work for me. This one does.

                                – Manuel Schmitzberger
                                Dec 23 '18 at 8:44















                              2














                              All of the above answers use double quotes (not all of them worked for my setup). This worked for me:



                              0 5 * * 3 /data/script.sh > /data/script_`date +%y%m%d`.log 2>&1





                              share|improve this answer




















                              • 1





                                What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                                – G-Man
                                Dec 23 '18 at 6:27











                              • The accepted answer simply doesn't work for me. This one does.

                                – Manuel Schmitzberger
                                Dec 23 '18 at 8:44













                              2












                              2








                              2







                              All of the above answers use double quotes (not all of them worked for my setup). This worked for me:



                              0 5 * * 3 /data/script.sh > /data/script_`date +%y%m%d`.log 2>&1





                              share|improve this answer















                              All of the above answers use double quotes (not all of them worked for my setup). This worked for me:



                              0 5 * * 3 /data/script.sh > /data/script_`date +%y%m%d`.log 2>&1






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Sep 25 '18 at 9:36

























                              answered Sep 25 '18 at 8:46









                              Manuel SchmitzbergerManuel Schmitzberger

                              1213




                              1213







                              • 1





                                What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                                – G-Man
                                Dec 23 '18 at 6:27











                              • The accepted answer simply doesn't work for me. This one does.

                                – Manuel Schmitzberger
                                Dec 23 '18 at 8:44












                              • 1





                                What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                                – G-Man
                                Dec 23 '18 at 6:27











                              • The accepted answer simply doesn't work for me. This one does.

                                – Manuel Schmitzberger
                                Dec 23 '18 at 8:44







                              1




                              1





                              What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                              – G-Man
                              Dec 23 '18 at 6:27





                              What are you saying that hasn’t already been said by the accepted answer? Are you saying that it works better without quotes than it does with quotes? (Hint: that’s very unlikely.)

                              – G-Man
                              Dec 23 '18 at 6:27













                              The accepted answer simply doesn't work for me. This one does.

                              – Manuel Schmitzberger
                              Dec 23 '18 at 8:44





                              The accepted answer simply doesn't work for me. This one does.

                              – Manuel Schmitzberger
                              Dec 23 '18 at 8:44

















                              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%2f29578%2fhow-can-i-execute-date-inside-of-a-cron-tab-job%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.