0

I've set anacron to run several tasks, but it seems to fail due to some sort of weird permissions error.

This is my 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
@daily  5   variety.daily   rsync -aAX $HOME/.config/variety/ /run/media/MYUSER/samsung/home/MYUSER/.config/variety/
@daily  3   testfile.daily  rsync -aAX $HOME/Documents/flag.hs /run/media/MYUSER/samsung/flag.hs
@weekly 5   st_apps.daily   rsync -aAX $HOME/.local/share/Steam/steamapps/ /run/media/MYUSER/samsung/home/MYUSER/.local/share/Steam/steamapps/
@weekly 15  st_ud.daily rsync -aAX $HOME/.local/share/Steam/userdata/ /run/media/MYUSER/samsung/home/MYUSER/.local/share/Steam/userdata/
@weekly 1   anacrontab.weekly   rsync -aAX /etc/anacrontab /run/media/MYUSER/samsung/home/anacrontab

This is the output of journalctl -b --no-pager --catalog | grep anacron

jan. 14 00:02:09 MYPC anacron[73073]: Anacron started on 2022-01-14
jan. 14 00:02:09 MYPC anacron[73073]: Can't open timestamp file for job cron.daily: Permission denied
jan. 14 00:02:09 MYPC anacron[73073]: Aborted
jan. 14 00:02:42 MYPC sudo[73113]:     MYUSER : TTY=pts/0 ; PWD=/home/MYUSER ; USER=root ; COMMAND=/usr/bin/dd bs=4k of=/etc/anacrontab
jan. 14 00:02:50 MYPC sudo[73124]:     MYUSER : TTY=pts/0 ; PWD=/home/MYUSER ; USER=root ; COMMAND=/usr/bin/dd bs=4k of=/etc/anacrontab

Could someone please prod me in the right direction?

System: Fedora 35

5
  • Does this help: superuser.com/questions/1270943/… Commented Jan 14, 2022 at 1:47
  • Unfortunately, it does not. All the permissions on folders are as they should be, but running anacron -fnd with root privilege works.
    – telometto
    Commented Jan 14, 2022 at 11:29
  • 1
    What does ls -al /etc/cron.daily return? Commented Jan 14, 2022 at 23:21
  • brave-browser, brave-key-updater, and rpm. All of which seem to contain scripts.
    – telometto
    Commented Jan 15, 2022 at 10:56
  • It's unclear who's running the jobs that you show. Is it root? How and from where are you invoking anacron?
    – Kusalananda
    Commented Jan 15, 2022 at 13:07

1 Answer 1

0

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!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .