Skip to content

Crontab job scheduling – Tips

  • How to schedule a cron job to run every 1st and 3rd Friday of the month

15 20 1-7,15-21 * * bash -c ‘. ~/.bashrc ; [ “`date +\%a`” = “Fri” ] && /my_server/scripts/backup.bsh >> /my_server/log/backup.log_`date +\%Y\%m\%d` 2>&1’

  • How to schedule a cron job to run every 2nd and 4th Friday of the month

05 20 8-14,22-28 * * bash -c ‘. ~/.bashrc ; [ “`date +\%a`” = “Fri” ] && /my_server/scripts/backup.bsh >> /my_server/scripts/backup.log_`date +\%Y\%m\%d` 2>&1’

  • How to schedule a cron job to run every first Saturday of each month at 2:10 PM

10 14 1-7 * * bash -c ‘. ~/.bashrc ; [ “`date +\%a`” = “Sat” ] && /my_server/scripts/backup.sh >> /my_server/scripts/backup.log_`date +\%Y\%m\%d` 2>&1’