0

I wanted to schedule a daily task using anacron. After some reading I added the below line to /etc/anacrontab:

@daily  10  price_scrape /home/pawel/Project_Inflation/run.sh >> /home/pawel/Project_Inflation/log/task_log 2>> /home/pawel/Project_Inflation/log/error_log

This works (script executes as expected) but is done hourly whilst it should be done once a day. Here is the output of grep 'cron' /var/log/syslog:

Jun 27 15:02:24 pawel-ubuntu anacron[399]: Anacron 2.3 started on 2019-06-27
Jun 27 15:02:24 pawel-ubuntu anacron[399]: anacron: /etc/anacrontab: Unknown named period on line 14, skipping
Jun 27 15:02:24 pawel-ubuntu anacron[399]: /etc/anacrontab: Unknown named period on line 14, skipping
Jun 27 15:02:24 pawel-ubuntu anacron[399]: Will run job `price_scrape' in 10 min.
Jun 27 15:02:24 pawel-ubuntu anacron[399]: Jobs will be executed sequentially
Jun 27 15:12:24 pawel-ubuntu anacron[399]: Job `price_scrape' started
Jun 27 15:12:53 pawel-ubuntu anacron[399]: Job `price_scrape' terminated
Jun 27 15:12:53 pawel-ubuntu anacron[399]: Normal exit (1 job run)
Jun 27 15:17:01 pawel-ubuntu CRON[721]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 27 16:02:24 pawel-ubuntu systemd[1]: Started Run anacron jobs.
Jun 27 16:02:24 pawel-ubuntu anacron[2762]: Anacron 2.3 started on 2019-06-27
Jun 27 16:02:24 pawel-ubuntu anacron[2762]: /etc/anacrontab: Unknown named period on line 14, skipping
Jun 27 16:02:24 pawel-ubuntu anacron[2762]: anacron: /etc/anacrontab: Unknown named period on line 14, skipping
Jun 27 16:02:24 pawel-ubuntu anacron[2762]: Will run job `price_scrape' in 10 min.
Jun 27 16:02:24 pawel-ubuntu anacron[2762]: Jobs will be executed sequentially
Jun 27 16:12:24 pawel-ubuntu anacron[2762]: Job `price_scrape' started
Jun 27 16:12:53 pawel-ubuntu anacron[2762]: Job `price_scrape' terminated

It seemed to me that anacron is actually ran by cron itself and on system start up, but to my surprise there is an anacron service and associated anacron timer which triggeres every hour. When I stop the service and the timer however the job will not run at all. Any suggestions as to why the daily period is not respected?

Thanks

3
  • @Rinzwind I thought about that, but the actual answer to OP's question is only in a comment there. Jun 27 '19 at 15:18
  • 1
    "Also, the manpage notes that, as of now, period_name can only be monthly. So instead of daily, one would have to use:" did it for me . Had to remove the ATs :X
    – Rinzwind
    Jun 27 '19 at 15:24
  • @Rinzwind good catch, I missed that. Jun 27 '19 at 15:25
1

The man page for anacrontab states

The period_name can only be set to monthly at the present time.

so your daily will not work and is causing the error message anacron: /etc/anacrontab: Unknown named period on line 14, skipping

Sourced from comments at Tell me where is mistake in anacron task?

1
  • Indeed changing it to 1 works, the job was not re-executed after I started the service again. Thanks. Jun 27 '19 at 15:24
1

A better approach for me is to drop an executable script in /etc/cron.daily/ and you have no more worries.

Not the answer you're looking for? Browse other questions tagged or ask your own question.