Ubuntu – Tell me where is mistake in anacron task

anacronbashcronscriptsxubuntu

I have tried to make this task for 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>."

this command well done from my xubuntu terminal

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

but when i started my notebook i saw in /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

Best Answer

The syntax of anacrontab is, according to the manpage:

Job-description lines are of one of these two forms:

      period  delay  job-identifier  command

      @period_name delay job-identify command

I'd say you are missing a job-identifier. So something like;

@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>."

Also, the manpage notes that, as of now, @period_name can only be @monthly. So instead of @daily, one would have to use:

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

Aside from this, notify-send would need the DISPLAY variable to be set. This is typically :0, but you can check using echo $DISPLAY in a terminal. Thus the anacrontab entry should look like:

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