Skip to content

Instantly share code, notes, and snippets.

@theodorosploumis
Forked from dcrystalj/startup.bat
Last active April 10, 2020 10:36
Show Gist options
  • Save theodorosploumis/0738cefd7474dfe57255 to your computer and use it in GitHub Desktop.
Save theodorosploumis/0738cefd7474dfe57255 to your computer and use it in GitHub Desktop.
Setup Cron jobs with crontab for Drupal 7.x and 8.x (also how to clear caches, flush image styles etc)
# Open crontab with nano
# env EDITOR=nano crontab -e
# Examples from https://crontab.guru
# 0 03 * * 1-5
# */15 * * * *
# 33 * * * *
0 03 * * 1-5 /usr/local/bin/curl "http://www.domain.com/cron.php?cron_key=vHhbh21L3NXkiF5wKb5QXg3EHCp1ODDvN5DM0gH9OzO" > /dev/null 2>&1
0 03 * * 1-5 /usr/local/bin/curl "MY-WEBSITE" > /dev/null 2>&1
# Clear caches Drupal 8.x, eg at minute 22 every 3 hours
22 */3 * * * cd /home/www/[CUSTOMER-FOLDER]/[DOMAIN]/www/ && /home/www/[CUSTOMER-FOLDER]/[DOMAIN]/www/vendor/drush/drush/drush cr > /dev/null 2>&1
# Clear caches Drupal 7.x, eg at minute 22 every 3 hours
22 */3 * * * cd /home/www/[CUSTOMER-FOLDER]/[DOMAIN]/www && /home/www/[CUSTOMER-FOLDER]/drush/drush cc all
# Flush image styles Drupal 8.x, eg at minute 22 every 3 hours
22 */3 * * * cd /home/www/[CUSTOMER-FOLDER]/[DOMAIN]/www/ && /home/www/[CUSTOMER-FOLDER]/[DOMAIN]/www/vendor/drush/drush/drush image:flush --all > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment