#!/usr/bin/env bash apt purge postfix apt-get install msmtp msmtp-mta mailutils read -p "Please enter the pass for cron@kjan.email: " pass echo "defaults port 465 tls on auth on syslog on tls_starttls off account default host box.kjan.email from cron@kjan.email user cron@kjan.email password $pass " >> /etc/msmtprc NEW_CRON_JOB=" MAILTO="jan@kjan.email" SHELL=/bin/bash HOME=/ " read -p "Enter usename for cron: " USERNAME # Replace with the actual username # Check if the line already exists to avoid duplicates if ! crontab -u "$USERNAME" -l | grep -Fq "$NEW_CRON_JOB"; then (crontab -u "$USERNAME" -l; echo "$NEW_CRON_JOB") | crontab -u "$USERNAME" - echo "Added '$NEW_CRON_JOB' to $USERNAME's crontab." else echo "'$NEW_CRON_JOB' already exists in $USERNAME's crontab. Skipping." fi