告诉我 anacron 任务中哪里出了错误?

告诉我 anacron 任务中哪里出了错误?

我曾尝试为 abacron 完成以下任务:

dm@dm-system:~$ cat /etc/anacrontab 
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
HOME=/root
LOGNAME=root

# These replace cron's entries
1   5   cron.daily  run-parts --report /etc/cron.daily
7   10  cron.weekly run-parts --report /etc/cron.weekly
@monthly    15  cron.monthly    run-parts --report /etc/cron.monthly
@daily 5 /home/dm/Devel/btsync && notify-send "Btsync loaded (pid `pidof btsync`)" "Link <a href='http://0.0.0.0:8888/gui/'>here</a>."

这个命令在我的 xubuntu 终端上完成得很好

/home/dm/Devel/btsync && notify-send "Btsync loaded (pid `pidof btsync`)" "Link <a href='http://0.0.0.0:8888/gui/'>here</a>."

但是当我启动笔记本时,我在 /var/syslog 中看到:

Aug 14 10:49:06 dm-system anacron[904]: Anacron 2.3 started on 2014-08-14
Aug 14 10:49:06 dm-system anacron[904]: Invalid syntax in /etc/anacrontab on line 14 - skipping this line
Aug 14 10:49:06 dm-system cron[841]: (CRON) INFO (pidfile fd = 3)
Aug 14 10:49:06 dm-system cron[998]: (CRON) STARTUP (fork ok)
Aug 14 10:49:06 dm-system cron[998]: (CRON) INFO (Running @reboot jobs)
Aug 14 10:49:07 dm-system anacron[904]: Will run job `cron.daily' in 5 min.
Aug 14 10:49:07 dm-system anacron[904]: Jobs will be executed sequentially
Aug 14 10:54:04 dm-system anacron[904]: Job `cron.daily' started
Aug 14 10:54:05 dm-system anacron[2616]: Invalid syntax in /etc/anacrontab on line 14 - skipping this line
Aug 14 10:54:05 dm-system anacron[2616]: Updated timestamp for job `cron.daily' to 2014-08-14

答案1

根据anacrontab手册页

职位描述可以采用以下两种形式之一:

      period  delay  job-identifier  command

      @period_name delay job-identify command

我想说你错过了一个job-identifier。所以类似于;

@daily 5 btsync-job /home/dm/Devel/btsync && notify-send "Btsync loaded (pid `pidof btsync`)" "Link <a href='http://0.0.0.0:8888/gui/'>here</a>."

此外,手册页指出,截至目前,@period_name只能是@monthly。因此@daily,人们必须使用 来代替 :

1 5 btsync-job /home/dm/Devel/btsync && notify-send "Btsync loaded ...

除此之外,notify-send还需要DISPLAY设置变量。这通常是:0,但您可以echo $DISPLAY在终端中使用来检查。因此,anacrontab条目应如下所示:

DISPLAY=:0
1 5 btsync-job /home/dm/Devel/btsync && notify-send "Btsync loaded ...

相关内容