![]() Special Crontab strings : run once at : run yearly on 1st Jan : same as : run on 1st of month every month : run once a : run daily at : same as Syntax To Use Special Command Run the backup script weekly sh /home/savan.patel/backup.sh Run backup script every sunday at midnight 0 0 * * 7 sh /home/savan.patel/backup.sh Special Crontab Stringsīesides operators, there are special strings defined by cron that are very easy to use. Run backup script every 5 hours * */5 * * * sh /home/savan.patel/backup.sh Run backup script every 5 mins */5 * * * * sh /home/savan.patel/backup.sh Let’s take some more examples to understand the usage of cron expressions. For example to run command at every 3 hours you would use */3 in your expression Example Run every 3 hours * */3 * * * sh /home/savan.patel/backup.sh Cron Expressions Usage This is step operator use to specify for terms like every hour. Example (Run at 5,6,7 am daily) 0 5-7 * * 1 sh /home/savan.patel/backup.sh Example (Run everyday at 5 am, 7 am and 10 am) 0 5,7,10 * * * sh /home/savan.patel/backup.sh * : Asterisk (*) is for every possible value, for example, * in minute would mean every minute Example (Run everyday at 5 am) 0 5 * * 1 sh /home/savan.patel/backup.sh Cron OperatorsĬron operators add flexibility in defining command timings. The expression takes the form – Cron expressions min hour day month dayOfWeek CommandĭayOfWeek : Day of week (0 - 7) Ĭommand: command to run as cron job.
0 Comments
Leave a Reply. |