Fedora
為什麼 anacron 不執行計劃的任務?
我已經設置
anacron
執行幾個任務,但由於某種奇怪的權限錯誤,它似乎失敗了。這是我的
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
這是的輸出
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
有人可以在正確的方向上刺激我嗎?
系統:Fedora 35
我
anacron
之前工作過,但不再工作了,所以我決定採取不同的方法。為了能夠在沒有升級權限的情況下執行它,您需要執行以下操作:
.anacron
使用命令在您的主目錄和兩個子目錄(etc
和spool
)中創建一個文件夾mkdir -p ~/.anacron/{etc,spool}
。etc
通過執行與touch $HOME/.anacron/etc/anacrontab
原始/etc/anacrontab
. 例如:# 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
- 在終端中,輸入
crontab -e
並添加以下內容:@hourly /usr/sbin/anacron -s -t $HOME/.anacron/etc/anacrontab -S $HOME/.anacron/spool
您可以測試等待 cron 執行每小時任務,也可以
anacron
通過 running 強制立即執行anacron -fnd -t $HOME/.anacron/etc/anacrontab -S $HOME/.anacron/spool/
。希望這對將來的其他人有所幫助!