Ubuntu 18.04 Cron job not running [duplicate]












1
















This question already has an answer here:




  • Unable to execute command in cron

    2 answers




I want to delete files from a folder that is created from another process with the 2019-02-21 format.



# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;


Update



Actually $(date was not working with cronjob. see the answer for solution.










share|improve this question















marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    It is best to call a script from cron. The script in turn can call date command and other commands.

    – WinEunuuchs2Unix
    Feb 22 at 11:33
















1
















This question already has an answer here:




  • Unable to execute command in cron

    2 answers




I want to delete files from a folder that is created from another process with the 2019-02-21 format.



# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;


Update



Actually $(date was not working with cronjob. see the answer for solution.










share|improve this question















marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    It is best to call a script from cron. The script in turn can call date command and other commands.

    – WinEunuuchs2Unix
    Feb 22 at 11:33














1












1








1









This question already has an answer here:




  • Unable to execute command in cron

    2 answers




I want to delete files from a folder that is created from another process with the 2019-02-21 format.



# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;


Update



Actually $(date was not working with cronjob. see the answer for solution.










share|improve this question

















This question already has an answer here:




  • Unable to execute command in cron

    2 answers




I want to delete files from a folder that is created from another process with the 2019-02-21 format.



# Clear every 6 hours, 5 minutes
*/5 */6 * * * find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ;


Update



Actually $(date was not working with cronjob. see the answer for solution.





This question already has an answer here:




  • Unable to execute command in cron

    2 answers








server 18.04 cron






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 22 at 12:04







AZ_

















asked Feb 21 at 11:25









AZ_AZ_

1166




1166




marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by steeldriver, karel, WinEunuuchs2Unix, Eric Carvalho, Charles Green Feb 23 at 17:22


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    It is best to call a script from cron. The script in turn can call date command and other commands.

    – WinEunuuchs2Unix
    Feb 22 at 11:33














  • 1





    It is best to call a script from cron. The script in turn can call date command and other commands.

    – WinEunuuchs2Unix
    Feb 22 at 11:33








1




1





It is best to call a script from cron. The script in turn can call date command and other commands.

– WinEunuuchs2Unix
Feb 22 at 11:33





It is best to call a script from cron. The script in turn can call date command and other commands.

– WinEunuuchs2Unix
Feb 22 at 11:33










2 Answers
2






active

oldest

votes


















1














Check if cron is running, may be you have it disabled/not installed:



leonid@Desktop:~$ /etc/init.d/cron status
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running)


And redirect error output of commands to some log file, to check what's wrong.






share|improve this answer































    1















    Thanks WinEunuuchs2Unix for the hint.




    Create an script in your home directory with chmod +x executable access I have done chmod 0755
    Go to /etc/crontab and enter the following line



    */5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1


    and it will run every 6 hours 5 minutes



    You can put this into your {your script name}.sh



    find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ; 





    share|improve this answer
































      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Check if cron is running, may be you have it disabled/not installed:



      leonid@Desktop:~$ /etc/init.d/cron status
      ● cron.service - Regular background program processing daemon
      Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
      Active: active (running)


      And redirect error output of commands to some log file, to check what's wrong.






      share|improve this answer




























        1














        Check if cron is running, may be you have it disabled/not installed:



        leonid@Desktop:~$ /etc/init.d/cron status
        ● cron.service - Regular background program processing daemon
        Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
        Active: active (running)


        And redirect error output of commands to some log file, to check what's wrong.






        share|improve this answer


























          1












          1








          1







          Check if cron is running, may be you have it disabled/not installed:



          leonid@Desktop:~$ /etc/init.d/cron status
          ● cron.service - Regular background program processing daemon
          Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
          Active: active (running)


          And redirect error output of commands to some log file, to check what's wrong.






          share|improve this answer













          Check if cron is running, may be you have it disabled/not installed:



          leonid@Desktop:~$ /etc/init.d/cron status
          ● cron.service - Regular background program processing daemon
          Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
          Active: active (running)


          And redirect error output of commands to some log file, to check what's wrong.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 21 at 12:22









          LeonidMewLeonidMew

          659619




          659619

























              1















              Thanks WinEunuuchs2Unix for the hint.




              Create an script in your home directory with chmod +x executable access I have done chmod 0755
              Go to /etc/crontab and enter the following line



              */5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1


              and it will run every 6 hours 5 minutes



              You can put this into your {your script name}.sh



              find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ; 





              share|improve this answer






























                1















                Thanks WinEunuuchs2Unix for the hint.




                Create an script in your home directory with chmod +x executable access I have done chmod 0755
                Go to /etc/crontab and enter the following line



                */5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1


                and it will run every 6 hours 5 minutes



                You can put this into your {your script name}.sh



                find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ; 





                share|improve this answer




























                  1












                  1








                  1








                  Thanks WinEunuuchs2Unix for the hint.




                  Create an script in your home directory with chmod +x executable access I have done chmod 0755
                  Go to /etc/crontab and enter the following line



                  */5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1


                  and it will run every 6 hours 5 minutes



                  You can put this into your {your script name}.sh



                  find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ; 





                  share|improve this answer
















                  Thanks WinEunuuchs2Unix for the hint.




                  Create an script in your home directory with chmod +x executable access I have done chmod 0755
                  Go to /etc/crontab and enter the following line



                  */5 */6 * * * root /home/john/{your script name}.sh >> /var/log/cronErrLog.txt 2>&1


                  and it will run every 6 hours 5 minutes



                  You can put this into your {your script name}.sh



                  find /data/ding/dong/$(date '+%Y-%m-%d') -type f -exec rm -f {} ; 






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 22 at 12:04

























                  answered Feb 22 at 11:55









                  AZ_AZ_

                  1166




                  1166















                      Popular posts from this blog

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

                      Mangá

                      Eduardo VII do Reino Unido