How to Schedule Jobs in Fedora 38 with systemd
Systemd is a system and service manager for Linux, which provides a number of features, including job scheduling. In this blog post, we will show you how to schedule jobs in Fedora 38 using systemd.
1. Create a service file
The first step is to create a service file for your job. This file will tell systemd how to run your job. The service file should be placed in the
The following is an example of a service file for a job that runs a script called
myscript.sh every day at 04:00
/path/to/myscript.sh with the actual path to your script.
2. Create a timer file in the same directory with the following content:
OnCalendar option specifies when the job should run, in the format
YYYY-MM-DD HH:MM:SS. In this case, we’re running the job at 4:00 AM every day.
Save the files and reload the
systemd daemon with
sudo systemctl daemon-reload. Enable the timer to start automatically at boot time, and start the timer with
sudo systemctl start myscript.timer.
Finally, verify that the timer and job are running with
sudo systemctl list-timers myscript.timer and
sudo systemctl status myscript.service.
Your job is now scheduled to run automatically at 4:00 AM every day. You can modify the
myscript.timer files to change the scheduling interval or other job settings as needed.
3. Reload the systemd daemon
Once you have created the service file, you need to reload the systemd daemon so that it can be aware of the new job. You can do this by running the following command:
sudo systemctl daemon-reload
4. Enable the job to start automatically at boot time
You can enable the job to start automatically at boot time by running the following command:
sudo systemctl enable myscript.service
5. Start the job
You can start the job immediately by running the following command:
sudo systemctl start myscript.service
6. Verify that the job is running
You can verify that the job is running by running the following command:
sudo systemctl status myscript.service
This will display the current status of the job, including whether it’s running, stopped, or failed.