4

Arch ARM comes with cronie cron daemon. However I can't find the system crontab file and running crontab -l as root returns no crontab for root.

systemctl is-enabled cronie reports enabled

I have a number of script in the /etc/cron.period directories but suspect they might not get executed. For example I have a script in cron.weekly that hasn't run for 9 days. It can be executed manually and has these file flags:

-rwxr--r--  1 root root 1,7K 24 apr 23.55 task1.cron*

How can I check that there's a schedule for the /etc/cron.period directories and where do I find the system crontab?

There's /etc/anacrontab but I'm not sure if it's used by the system. There's no /etc/crontab.

update: journalctl -u cronie reports No journal files were found., but I have the fillowing in /var/log/everything.log:

May 18 00:01:01 pi CROND[30893]: (root) CMD (run-parts /etc/cron.hourly)
May 18 00:01:01 pi anacron[30898]: Anacron started on 2013-05-18
May 18 00:01:01 pi anacron[30898]: Will run job `cron.daily' in 6 min.
May 18 00:01:01 pi anacron[30898]: Will run job `ron.weekly' in 26 min.
May 18 00:01:01 pi anacron[30898]: Jobs will be executed sequentially
May 18 00:07:01 pi anacron[30898]: Job `cron.daily' started
May 18 00:08:00 pi anacron[30898]: Job `cron.daily' terminated
May 18 00:27:01 pi anacron[30898]: Job `ron.weekly' started
May 18 00:27:01 pi anacron[30898]: Job `ron.weekly' terminated
May 18 00:27:01 pi anacron[30898]: Normal exit (2 jobs run)
May 18 01:01:01 pi CROND[32633]: (root) CMD (run-parts /etc/cron.hourly)
May 18 02:01:01 pi CROND[32645]: (root) CMD (run-parts /etc/cron.hourly)
May 18 03:01:01 pi CROND[32653]: (root) CMD (run-parts /etc/cron.hourly)

anacron appears to be active but the weekly job seems to be missing the character c at the beginning of its name. I wonder if could have anything to do with weekly scripts not running.

update 2: I restored (an unedited) /etc/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

I then ran anacron -T to test /etc/anacrontab validity, following the anacron man page. It reported no errors.

I then tried anacron -n -d and got this:

Anacron started on 2013-05-18
Checking against 25 with 30
Normal exit (0 jobs run)

That seems odd. I had expected to run the three jobs (cron.daily, cron.weekly, cron.monthly). -n is supposed to run jobs immediately but that seems not to happen.

update 3: I noticed that run-parts --test doesn't list scripts that have extensions. I also needed to add -f to anacron to ignore timestamps in order to force execution of jobs.

update final: /etc/anacrontab is indeed the system crontab as @Lekensteyn indicated. The reason some of my scripts were not running was because those script names contained dots (e.g. task1.cron) which is not accepted by run-parts, as documented in its man page:

If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of ASCII upper- and lower-case letters, ASCII digits, ASCII underscores, and ASCII minus-hyphens.

I can now consistently force jobs to run by executing anacron -dfn cron.weekly or some other job name, or all jobs if the job name is omitted.

2

In order to test whether a cron job has run, check your syslog. On Arch Linux with cronie, this can be done with journalctl -u cronie.

cronies daemon is called crond. From its manual page:

Cron checks these files and directories:

/etc/crontab

system crontab. Nowadays the file is empty by default. Originally it was usually used to run daily, weekly, monthly jobs. By default these jobs are now run through anacron which reads /etc/anacrontab configuration file. See anacrontab(5) for more details.

/etc/cron.d/

directory that contains system cronjobs stored for different users.

The file /etc/anacrontab is indeed used to run the tasks:

#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

As for /etc/cron.hourly, the file /etc/cron.d/0hourly configures that:

01 * * * * root run-parts /etc/cron.hourly

crontab -l only lists user crons located in /var/spool/cron/, not the ones in /etc/.

  • Thank you for this. It clarifies and confirms some things. For some reason weekly (at least) scripts are not run even though anacron shows activity. I've updated my question with more information. – seron May 18 '13 at 8:25
  • Can you ensure that your system is up-to-date and that the anacrontab file is not corrupted? My Arch Linux installation on the Pi shows the name correctly. – Lekensteyn May 18 '13 at 8:52
  • I had edited anacrontaband had accidentally deleted the c, changing the job-identifier. The command was unchanged though. I've now restored it from backup. Could I speed up weekly by setting the period to 1? – seron May 18 '13 at 9:20
  • seron, weekly means every seven days. If you change it to one, then you have effectively a daily job. If you want to test your cron, why not move it to /etc/cron.hourly or even create a crontab entry that executes in a minute? – Lekensteyn May 18 '13 at 9:24
  • I see you point. My idea is to quicker verify that anacron does run its job commands by increasing the job frequency. It seems that daily is the shortest frequency available in anacrontab. – seron May 18 '13 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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