Anacron jobs not running

I’m getting a strange permissions error in my journal from cron/anacron… this is the output of journalctl -b --no-pager --catalog | grep anacron:

jan. 12 19:46:00 mypc anacron[3899]: Anacron started on 2022-01-12
jan. 12 19:46:00 mypc anacron[3899]: Can't open timestamp file for job cron.daily: Permission denied
jan. 12 19:46:00 mypc anacron[3899]: Aborted

And this is my anacrontab (/etc/anacrontab):

# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days   delay in minutes   job-identifier   command
1	5	cron.daily		nice run-parts /etc/cron.daily
7	25	cron.weekly		nice run-parts /etc/cron.weekly
@monthly 45	cron.monthly		nice run-parts /etc/cron.monthly

@daily	1	bashrc.daily	rsync -aAX $HOME/.bashrc /run/media/myuser/samsung/home/myuser/.bashrc
@daily	1	bash_aliases.daily	rsync -aAX $HOME/.bash_aliases /run/media/myuser/samsung/home/myuser/.bash_aliases

Needless to say that nothing is getting synced; at first I thought it might’ve been due to me setting up my box using Ansible, so I tried dnf reinstall to see if that would fix the permissions, but that didn’t help.

Can someone prod me in the right direction?

Many thanks :blush:

EDIT: could it be the MAILTO user?

May be you want to check with ls -l /etc/cron.* and make sure file under each folder cron.daily, cron.weekly, and corn.monthly are executable (chmod 755). Especially for cron.daily since your error message:

Thank you for the reply, Syaifur.
I have checked the permissions of the files and they are all set to 755. However, I checked what files I do have under the various folders, and none of them seem to include the commands I have put in the anacrontab.
For example, the file /etc/cron.daily/rpm seems to be a shell-script.

My anacron worked earlier but doesn’t work any more, so I decided to take a different approach. To be able to run it without escalated privileges, you will need to do as follows:

  1. Create an .anacron folder in your home dir and two subdirs (etc and spool) by using the command mkdir -p ~/.anacron/{etc,spool}.
  2. Create a new file in the etc dir by running touch $HOME/.anacron/etc/anacrontab with contents similar to the original /etc/anacrontab. E.g.:
# Personal anacrontab

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

#period in days   delay in minutes   job-identifier   command
@daily	1	bashrc.daily	rsync -aAXr $HOME/.bashrc /run/media/myuser/samsung/home/myuser/.bashrc
@daily	1	bash_aliases.daily	rsync -aAXr $HOME/.bash_aliases /run/media/myuser/samsung/home/myuser/.bash_aliases
  1. In the terminal, enter crontab -e and add the following:
@hourly /usr/sbin/anacron -s -t $HOME/.anacron/etc/anacrontab -S $HOME/.anacron/spool

You can test wait for cron to execute the hourly task, or you can force anacron to run immediately by running anacron -fnd -t $HOME/.anacron/etc/anacrontab -S $HOME/.anacron/spool/.

Hope this helps someone else in the future!

1 Like