Improve logging of cron jobs

This commit is contained in:
myve 2025-12-18 09:42:20 +00:00
commit 9409bfa6bf
4 changed files with 27 additions and 40 deletions

View file

@ -25,7 +25,7 @@ RUN apt remove -y nano* exim*; \
&& apt dist-upgrade -y \
&& bash -c "echo \"postfix postfix/main_mailer_type string 'Internet Site'\" | debconf-set-selections" \
&& apt install -y \
busybox-syslogd rsync \
busybox busybox-syslogd rsync \
ca-certificates \
git wget bind9-host acl dbconfig-no-thanks at \
nginx \
@ -40,10 +40,15 @@ RUN apt remove -y nano* exim*; \
&& rm -r -f /var/lib/apt/lists \
# Create vmail user
&& adduser vmail --system --group --uid 600 --disabled-login --home /var/vmail/ --quiet \
# Create cron folders
&& mkdir -p /etc/periodic/{daily,weekly}/ /var/spool/cron/crontabs/ \
# Installer
&& /tmp/installer.sh \
&& rm /tmp/installer.sh
# Add crontab
ADD ubuntu/cron /var/spool/cron/crontabs/root
# Expose ports
EXPOSE 25
EXPOSE 80

View file

@ -5,43 +5,4 @@ then
echo "Cron not detected, exiting..."
exit 1
fi
ln -s /usr/share/webapps/roundcube/bin/cleandb.sh /etc/periodic/daily/roundcube-cleandb
ln -s /usr/local/bin/postwhite/postwhite /etc/periodic/daily/postwhite
ln -s /usr/local/bin/postwhite/scrape_yahoo /etc/periodic/weekly/postwhite_scrape_yahoo
crond -b -l 0 -L /var/log/mail/cron.log
# # Start at daemon
# atd
#
# # Roundcube cleanup (daily)
# while true
# do
# at -f /usr/share/webapps/roundcube/bin/cleandb.sh midnight
# sleep 1d
# done &
#
# # Update Postscreen Whitelists (daily)
# while true
# do
# at -f /usr/local/bin/postwhite/postwhite midnight
# sleep 1d
# done &
#
# # Update Yahoo! IPs for Postscreen Whitelists (weekly)
# while true
# do
# at -f /usr/local/bin/postwhite/scrape_yahoo midnight sunday
# sleep 7d
# done &
# # Refresh ssl keys daily
# # https://www.golinuxcloud.com/renew-self-signed-certificate-openssl/
# while true
# do
# sleep 1d
# openssl x509 -x509toreq -in /etc/ssl/dovecot/tls.pem -signkey /etc/ssl/dovecot/tls.key -out /tmp/new-certificate-sign-request.csr
# openssl x509 -req -days 3650 -in /tmp/new-certificate-sign-request.csr -signkey /etc/ssl/dovecot/tls.key -out /etc/ssl/dovecot/tls.pem
# rm /tmp/new-certificate-sign-request.csr
# dovecot reload
# postfix reload
# done &

View file

@ -504,3 +504,17 @@ cat >/etc/syslog.conf <<- syslog
mail.info /var/log/mail/maillog
mail.* /var/log/mail/maillog.debug
syslog
###############
#//
#// Cron
#//
###############
install /dev/stdin /etc/periodic/daily/daily <<- daily
/usr/share/webapps/roundcube/bin/cleandb.sh >>/var/log/mail/cron.daily.log 2>&1
/usr/local/bin/postwhite/postwhite >>/var/log/mail/cron.daily.log 2>&1
daily
install /dev/stdin /etc/periodic/weekly/weekly <<- weekly
/usr/local/bin/postwhite/scrape_yahoo >>/var/log/mail/cron.weekly.log 2>&1
weekly

7
build/ubuntu/cron Normal file
View file

@ -0,0 +1,7 @@
# do daily/weekly/monthly maintenance
# min hour day month weekday command
*/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly