Do not use scripts with a . extension! Do not use ~ in paths!
useful commands / locations / vars / …
sudo update-alternatives --config editor # change from nano to vim sudo -e /etc/anacrontab # anacron config watch tac /var/log/syslog # info abt crontab execution MAILTO=max → crontab output stored in: watch tac /var/mail/max ll /var/spool/anacron # see crontab execution timestamps
run scripts as another user (to take over permissions, env vars, …) use systemd timers!
sudo visudoroot ALL=(max) NOPASSWD: /home/max/.dotfiles/secrets/bin/full_restic_backupsudo -e /etc/anacrontab# period, delay, job identifier, command7 7 su max -c “/path/to/command”
Home needs to be set separately, same with potentially which shell to use, see below for example anacrontab.
Note also that this will only include paths that are in your login shell.
And if you use ssh you’ll need to ssh-keyscan <hostname> >> ~/.ssh/known_hosts for each host.
tac /var/mail/max | sed "/^From /q" | tac
To log to a logfile:
LOGFILE=/home/max/logs/full_restic_backup.log{ echo "Starting full_restic_backup at $(date)"} >> "$LOGFILE" 2>&1
configs
(for up to date stuff pls see the secrets dotfiles repo!)
# /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/bash # some stuff might need bash instead of default shHOME=/home/max # needed for some scripts that rely on $HOMELOGNAME=maxMAILTO=maxPATH=home/max/.local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$PATH# These replace cron's entries 1 5 cron.daily run-parts --report /etc/cron.daily7 10 cron.weekly run-parts --report /etc/cron.weekly@monthly 15 cron.monthly run-parts --report /etc/cron.monthly1 10 full_restic_backup sudo -u max /home/max/.dotfiles/secrets/bin/full_restic_backup