I have the following cron job in /etc/cron.d/backup:
*/1 * * * * backupbot /home/backupbot/bin/backup-script.sh
Basically, I want the backup-script.sh to run every minute (and the user backupbot should be executing the job).
The /home/backupbot/bin/backup-script.sh file is owned by backupbot (and he has "x" permission on it). The file looks as follows:
#!/bin/bash
set -e
{
BACKUP_DIR=/var/app/backups
STORAGE_ACCOUNT_URL=https://myserver/backups
BACKUP_FILE=$(ls $BACKUP_DIR -t | head -1)
if [ -z "$BACKUP_FILE" ]; then
echo "There are no backups to synchronize"
exit 0
fi
azcopy login --identity
azcopy copy $BACKUP_DIR/$BACKUP_FILE $STORAGE_ACCOUNT_URL/$BACKUP_FILE
} >/tmp/cron.backup-script.$$ 2>&1
Normally, any output should be logged into /tmp/cron.backup-script.xxxx. Such a file is never created.
The only evidence that the job is being noticed by Cron is the following output of systemctl status cron.service:
● cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2021-04-13 09:59:08 UTC; 6h ago
Docs: man:cron(8)
Main PID: 1086 (cron)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/cron.service
└─1086 /usr/sbin/cron -f
Apr 13 16:00:01 my-vm CRON[17201]: pam_unix(cron:session): session closed for user root
Apr 13 16:00:01 my-vm CRON[17198]: pam_unix(cron:session): session closed for user root
Apr 13 16:00:01 my-vm CRON[17199]: pam_unix(cron:session): session closed for user root
Apr 13 16:01:01 my-vm CRON[17402]: pam_unix(cron:session): session opened for user root by (uid=0)
Apr 13 16:01:01 my-vm CRON[17403]: (root) CMD ([ -f /etc/krb5.keytab ] && [ \( ! -f /etc/opt/omi/creds/omi.keytab \) -o \( /etc/krb5.keytab -nt /etc/opt/omi/creds/omi.keytab \) ] &&
Apr 13 16:01:01 my-vm CRON[17401]: pam_unix(cron:session): session opened for user backupbot by (uid=0)
Apr 13 16:01:01 my-vm CRON[17404]: (backupbot) CMD (/home/backupbot/bin/backup-script.sh)
Apr 13 16:01:01 my-vm CRON[17402]: pam_unix(cron:session): session closed for user root
Apr 13 16:01:01 my-vm CRON[17401]: (CRON) info (No MTA installed, discarding output)
Apr 13 16:01:01 my-vm CRON[17401]: pam_unix(cron:session): session closed for user backupbot
It mentions something about sessions for backupbot. How can I investigate further?