# /etc/cron.d/hitechcloud: crontab entries for the HiTechCloudPanel server
#
#
# This file is used by HiTechCloudPanel to schedule cronjobs
#
# It should NOT be edited manually,
# instead edit from HiTechAdmin > Advanced > System CronJobs
#
# To add crons, use the crontab as root user.
#
# Important Note!  This cronjob will NOT be executed if you are
# running systemd as your init system.  If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob.  For
# more details, see the systemd.timer manpage.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# STATISTICS
0 * * * * root /usr/local/bin/hitechcloudcli docker-collect_stats --all && echo "$(date) Resource usage data updated" >> /var/log/hitechcloud/admin/cron.log
*/5 * * * * root /usr/local/bin/hitechcloudcli user-quota && echo "$(date) Collected disk and inodes usage for all users" >> /var/log/hitechcloud/admin/cron.log
30 2 * * * root /usr/local/bin/hitechcloudcli domains-stats && echo "$(date) Domain statistics collected" >> /var/log/hitechcloud/admin/cron.log
0 4 * * * root /usr/local/bin/hitechcloudcli websites-pagespeed --all && echo "$(date) Google PageSpeed data collected for all domains" >> /var/log/hitechcloud/admin/cron.log
0 5 */2 * * root /usr/local/bin/hitechcloudcli websites-vulnerability --all && echo "$(date) WordPress websites scanned for known vulnerabilities" >> /var/log/hitechcloud/admin/cron.log
0 */4 * * * root /usr/local/bin/hitechcloudcli files-calculate_resellers_storage && echo "$(date) Calculated storage usage for all reseller accounts" >> /var/log/hitechcloud/admin/cron.log

# MAINTENANCE
15 0 * * * root /usr/local/bin/hitechcloudcli update && echo "$(date) System update executed" >> /var/log/hitechcloud/admin/cron.log
0 */8 * * * root /usr/local/bin/hitechcloudcli ftp-users && echo "$(date) FTP users file recreated" >> /var/log/hitechcloud/admin/cron.log
45 1 * * * root /usr/local/bin/hitechcloudcli email-server pflogsumm && echo "$(date) Generated email summary report for HiTechAdmin > Emails > Summary Reports" >> /var/log/hitechcloud/admin/cron.log
45 4 * * * root /usr/local/bin/hitechcloudcli files-purge_trash && echo "$(date) Executed purging Trash folder for all users" >> /var/log/hitechcloud/admin/cron.log
# Every five minutes, and not on any other interval: the outbound send counter
# keeps twelve five-minute buckets and calls their sum "the last hour". Run it
# less often and the hour is measured out of stale buckets; run it more often
# and the same five minutes is counted twice.
*/5 * * * * root /usr/local/bin/hitechcloudcli email-sendlimit enforce >> /var/log/hitechcloud/admin/cron.log 2>&1
0 0 1 * * root /usr/local/bin/hitechcloudcli waf-update && echo "$(date) Executed OWASP CRS update - view logs with: hitechcloudcli waf-update log" >> /var/log/hitechcloud/admin/cron.log
0 1 * * 0 root /usr/local/bin/hitechcloudcli backup && echo "$(date) Executed system backup - view logs from: HiTechAdmin > Backups > System > Runs" >> /var/log/hitechcloud/admin/cron.log
0 0 * * 0 * root /usr/local/bin/hitechcloudcli files-malware_scan --all && echo "$(date) Executed ClamAV scan for all users" >> /var/log/hitechcloud/admin/cron.log
59 23 31 2 * root /usr/local/bin/hitechcloudcli docker-backup && echo "$(date) Executed Backup for all users" >> /var/log/hitechcloud/admin/cron.log

# MONITORING
*/5 * * * * root /usr/local/bin/hitechcloudcli sentinel && echo "$(date) Notifications script executed" >> /var/log/hitechcloud/admin/cron.log
45 11 * * * root /usr/local/bin/hitechcloudcli sentinel --report && echo "$(date) Daily Usage Report generated" >> /var/log/hitechcloud/admin/cron.log
@reboot root /usr/local/bin/hitechcloudcli sentinel --startup && echo "$(date) Notifications script executed at startup" >> /var/log/hitechcloud/admin/cron.log

# COMPLIANCE
# Every five minutes: one uptime observation per service, which is what the
# public status page shows and what the SLA credit is computed from. The
# status page calls an observation stale after fifteen minutes, so three
# missed runs is the point at which it stops presenting the last one as
# current - run this less often and the page reads "unknown" most of the time.
*/5 * * * * root /usr/local/bin/hitechcloudcli compliance-run -probe >> /var/log/hitechcloud/admin/cron.log 2>&1
# Hourly: copy new lines from the panel's login and activity logs into the
# tamper-evident audit chain. Hourly rather than daily because the panel trims
# a user's activity.log once it passes its size limit, and anything trimmed
# before this has run is gone.
7 * * * * root /usr/local/bin/hitechcloudcli compliance-run -ingest >> /var/log/hitechcloud/admin/cron.log 2>&1
# Just after midnight UTC: seal yesterday, once, and report any rotation rule
# that would discard a log before Nghị định 53/2022/NĐ-CP allows. The seal
# anchor is in this job's output - copy it somewhere off this server, because
# a seal that never leaves the machine protects against nothing an operator
# with root cannot undo.
20 0 * * * root /usr/local/bin/hitechcloudcli compliance-run -seal -check >> /var/log/hitechcloud/admin/cron.log 2>&1
