I wanted to set up an anacron task to run a backintime backup once a day (Ubuntu 20.04.3 LTS). If you schedule this using the backintime GUI, the normal crontab is being used, but for my use case this is not suitable: I usually have my computer on standby when I'm not using it, so the cronjob would just be discarded if I don't have the computer running at that exact scheduled time. What I did instead was create a script in the cron.daily directory, so that anacron takes care of it, which also supports delayed execution in case of standby or the computer being shut down for some time. I added the following command:
sudo -i -u samuel /usr/bin/nice -n19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime backup-job >/dev/null
This is exactly what backintime adds to the crontab, so I was sure it would work just fine when using anacron. But that's not the case: The job is started just fine, but the backup never finishes. The syslog output is the following:
backintime (samuel/1): INFO: Lock
backintime (samuel/1): WARNING: Inhibit Suspend failed.
backintime (samuel/1): INFO: mount ssh: [...]
backintime (samuel/1): INFO: Take a new snapshot. Profile: 1 Main profile
backintime (samuel/1): INFO: Call rsync to take the snapshot
[... around 10 seconds later ...]
anacron[1082]: Job `cron.daily' terminated (mailing output)
anacron[1082]: anacron: Can't find sendmail at /usr/sbin/sendmail, not mailing output
anacron[1082]: Can't find sendmail at /usr/sbin/sendmail, not mailing output
systemd[1]: anacron.service: Killing process 7920 (python3) with signal SIGKILL.
anacron[1082]: Normal exit (1 job run)
systemd[1]: anacron.service: Killing process 7958 (ssh-agent) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8107 (ssh) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8109 (sshfs) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8112 (python3) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8126 (rsync) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8127 (ssh) with signal SIGKILL.
systemd[1]: anacron.service: Killing process 8123 (QXcbEventQueue) with signal SIGKILL.
systemd[1]: anacron.service: Succeeded.
I find this situation rather weird, because why would anacron deliberately kill my processes? So what happens, as far as I interpret it, is that the command I'm executing in my backup script exits rather quickly, as its only task is to spin off some worker processes like python, ssh, rsync etc, and once they're running in the background, the launcher quits. So far so good, but anacron apparently thinks it's its duty to kill off all descendants of the original backup script once the script is done. But how can I prevent it from doing so? Do I really need to manually find out the descendant PIDs and wait for all of them to be done, before exiting the backup script?
I haven't found any info on this behavior online, so I would be glad if someone had any advice on how to proceed here.