How to run a cron job on every Monday, Wednesday and Friday?

后端 未结 7 930
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 06:18

How can one run a cron job for every Monday, Wednesday and Friday at 7:00 pm?

相关标签:
7条回答
  • 2020-12-08 06:33

    Use crontab to add job

      crontab -e
    

    And job should be in this format:

      00 19 * * 1,3,5 /home/user/somejob.sh
    
    0 讨论(0)
  • 2020-12-08 06:33

    Use this command to add job

    crontab -e
    

    In this format:

    0 19 * * 1,3,5 /path to your file/file.php
    
    0 讨论(0)
  • 2020-12-08 06:34

    Use crontab to add job

    0 0 9 ? * MON,WED,FRI *
    

    The above expression will run the job at 9 am on every mon, wed and friday. You can validate this in : http://www.cronmaker.com/

    0 讨论(0)
  • 2020-12-08 06:37

    The rule would be:

    0 19 * * 1,3,5
    

    I suggest that you use http://corntab.com for having a very convenient GUI to create your rules in the future :)

    0 讨论(0)
  • 2020-12-08 06:38

    This is how I configure it on my server:

    0  19  *  *  1,3,5 root bash /home/divo/data/support_files/support_files_inc_backup.sh
    

    The above command will run my script at 19:00 on Monday, Wednesday, and Friday.

    NB: For cron entries for day of the week (dow)

    0 = Sunday
    1 = Monday
    2 = Tuesday
    3 = Wednesday
    4 = Thursday
    5 = Friday
    6 = Saturday
    
    0 讨论(0)
  • 2020-12-08 06:47

    Here's my example crontab I always use as a template:

        # Use the hash sign to prefix a comment
        # +---------------- minute (0 - 59)
        # |  +------------- hour (0 - 23)
        # |  |  +---------- day of month (1 - 31)
        # |  |  |  +------- month (1 - 12)
        # |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)
        # |  |  |  |  |
        # *  *  *  *  *  command to be executed
        #--------------------------------------------------------------------------
    

    To run my cron job every Monday, Wednesady and Friday at 7:00PM, the result will be:

          0 19 * * 1,3,5 nohup /home/lathonez/script.sh > /tmp/script.log 2>&1
    

    source

    0 讨论(0)
提交回复
热议问题