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.
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
- Each job can be configured to run in a specific environment (see
- 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.
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)
The File scheduledReboot.service contains:
ExecStart=/usr/bin/systemctl --force reboot
The file scheduledReboot.timer contains:
- And finally start the jobs:
sudo systemctl start scheduledReboot.timer
sudo systemctl enable scheduledReboot.timer
- Check if the job is successfully created:
sudo systemctl list-timers --all
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.