Create A Systemd Timer
Systemd timers are a powerful alternative to cron
for scheduling tasks, especially when you want better integration with system events like startup or specific conditions. Example of creating a simple systemd timer is given below -
Example: Running a Command Automatically After System Boot
1. Create a systemd service file, for example: test_timer.service
2. Now, create a timer file with the same name, for example: test_timer.timer
Note: OnBootSec=5m
ensures the service starts 5 minutes after the system boots up. Adjust the value based on your needs (e.g., 10s
for 10 seconds)
3. Enable & Start the Systemd Timer
To check if the Systemd timer is enabled, we can use systemctl list-timers
command to list out the various Systemd timer enabled on the system.
Source(s):
Last updated