Skip to content

095 - Crontab

System crontab with commented schedule explanations. This is an example of a MAML document.

maml
# System crontab
{
  SHELL: "/bin/bash"
  PATH: "/usr/local/bin:/usr/bin:/bin"

  MAILTO: "Toy.Waelchi@hotmail.com"

  jobs: {
    # Full database backup at 2:00 AM daily
    backup: {
      schedule: "0 2 * * *"
      command: """
/usr/local/bin/backup.sh --target /mnt/backup
  --compress gzip
  --notify Xander15@gmail.com
"""
    }

    # Renew SSL certificates on the 1st of each month
    certbot: {
      schedule: "0 0 1 * *"
      command: "certbot renew --quiet"
    }

    # Weekly log rotation and cleanup
    logrotate: {
      schedule: "0 0 * * 0"
      command: """
/usr/sbin/logrotate /etc/logrotate.conf
find /var/log -name "*.gz" -mtime +30 -delete
"""
    }
  }
}

See Also