Arch Linux - How to run a cron job?

There is no crond.service on Arch Linux. As the Arch Wiki makes perfectly clear:

There are many cron implementations, but none of them are installed by default as the base system uses systemd/Timers instead.

Consequently, if you want to use cron, you have to choose which of the many implementations you will install, and then start that specific service.

You don't just randomly type systemctl enable nonexistent.service and then wonder why it isn't running...

If you want cronie, then you install cronie and start it with:

pacman -Syu cronie
systemctl enable --now cronie.service

The Arch documentation is generally very clear; if you read the pages you linked to more carefully, you should find out what you need.


If I understand you right, you mean with...

How to run a 'cron' job

...scheduled events on arch Linux. That's pretty simple using systemd/Timers as a cron replacement.

Although cron is arguably the most well-known job scheduler, systemd timers can be an alternative.

Benefits

The main benefits of using timers come from each job having its own systemd service. Some of these benefits are:

  • Jobs can be easily started independently of their timers. This simplifies debugging.
  • Each job can be configured to run in a specific environment (see systemd.exec(5)).
  • Jobs can be attached to cgroups.
  • Jobs can be set up to depend on other systemd units.
  • Jobs are logged in the systemd journal for easy debugging.

...as mentioned here

If you have to use cron it is still possible and described here.


To make this answer a useful one, a minimal example for a daily automatic scheduled reboot at 01:30.

1. Create two files, one service file and one timer file. Both names (.timer and .service) have to match. F.e.:

sudo vim /usr/lib/systemd/system/scheduledReboot.service

sudo vim /usr/lib/systemd/system/scheduledReboot.timer

(The folder /usr/lib/systemd/system/... is the default folder containing all .service files just fyi)

2.1 The File scheduledReboot.service contains:

[Unit]
Description=Scheduled Reboot

[Service]
Type=simple
ExecStart=/usr/bin/systemctl --force reboot

2.2 The file scheduledReboot.timer contains:

[Unit]
Description=Reboot Scheduling.

[Timer]
OnCalendar=*-*-* 01:30:00

[Install]
WantedBy=multi-user.target
  1. And finally start the jobs:

sudo systemctl start scheduledReboot.timer

sudo systemctl enable scheduledReboot.timer

  1. Check if the job is successfully created:

sudo systemctl list-timers --all

and/or

sudo systemctl status scheduledReboot.timer

..that shows stuff like:

Trigger: Sun 2020-05-31 01:30:00 EDT; 10h left


I personally really like the systemd / .service approach since I use all my system jobs with systemctl like automatic mounting my nfs drives and so on and it works really well and efficient.