Questions tagged [systemd-timer]
149 questions
141
votes
4 answers
Cron vs systemd timers
It was recently pointed out to me that an alternative to cron exists, namely systemd timers.
However, I know nothing about systemd or systemd timers. I have only used cron.
There is a little discussion in the Arch Wiki. However, I'm looking for a…
Faheem Mitha
- 34,649
- 32
- 119
- 183
66
votes
2 answers
systemd timer every 15 minutes
I'm trying to make a systemd timer that runs every 15 minutes. Right now I have:
timer-fifteen.timer:
[Unit]
Description=15min timer
[Timer]
OnBootSec=0min
OnCalendar=*:*:0,15,30,45
Unit=timer-fifteen.target
[Install]
WantedBy=basic.target …
Lily Hahn
- 763
- 1
- 5
- 5
51
votes
1 answer
Which is the correct way to disable a systemd timer unit?
I've successfully migrated a few of my cron jobs over to systemd. I followed some guides and have taken the standard approach of creating 3 files:
myjob.timer - systemd timer unit
myjob.service - systemd service unit
myjob.sh
As you can probably…
bitofagoob
- 1,335
- 2
- 15
- 24
33
votes
4 answers
Is there a way to know when a systemd timer will run next?
I am testing a systemd timer and trying to override its default timeout, but without success. I'm wondering whether there is a way to ask systemd to tell us when the service is going to be run next.
Normal file…
Alexis Wilke
- 2,697
- 2
- 19
- 42
12
votes
2 answers
Pipe output of script through Exec in systemd service?
I'm trying to set up a systemd service in order to launch a set of files on a daily basis (different types of journals) from directories based off the date. For example, a todo list for today would be located…
Joshua Ferguson
- 165
- 1
- 1
- 7
12
votes
1 answer
systemd.unit `RequiresMountsFor=` vs `ConditionPathIsDirectory=`
I am about to write service that rsync --delete directory /mnt/foo to remote server. However because of --delete option, I'd like to not run it unless /mnt/foo is mounted, as this might result in deletion of all files on remote.
What to achieve it…
Grzegorz Wierzowiecki
- 13,865
- 23
- 89
- 137
11
votes
1 answer
I'm writing a systemd timer. What value should I use for WantedBy?
In various examples, I have seen all of these different choices suggested:
WantedBy=timers.target
WantedBy=multi-user.target
WantedBy=basic.target
WantedBy=default.target
WantedBy=mytimer.target (custom user-defined name)
However, in the examples…
MountainX
- 17,168
- 59
- 155
- 264
11
votes
2 answers
systemd timer every 2 hours at 30 minutes past the hour?
There are several good references on systemd timers including this one:
systemd.time
Unfortunately, it still isn't clear to me how to create a timer that will run periodically, but at a specific number of minutes after the top of the hour.
I want…
MountainX
- 17,168
- 59
- 155
- 264
10
votes
1 answer
Cannot override systemd timer with specific time
I use systemd-cron which creates unit files under /lib/systemd. The unit file for cron-daily.timer has
[Timer]
OnCalendar=daily
This triggers the scripts at midnight. I want them to trigger at 3am instead.
If I create override.conf in the…
Steve
- 460
- 4
- 14
10
votes
3 answers
Removing a timer created with "systemd-run --on-calendar"
I've created a systemd job using systemd-run --on-calendar .... Now I've replaced it with proper .timer and .service files, but I'm not able to remove the old one. I can stop it and disable it, but when I call systemctl list-timers it still appears…
Jörg Mäder
- 203
- 2
- 7
10
votes
2 answers
using systemd timers instead of cron
I am on Arch Linux where I am trying to create a systemd timer as a cron alternative for hibernating my laptop on low battery. So I wrote these three files:
/etc/systemd/system/battery.service
[Unit]
Description=Preko skripte preveri stanje…
71GA
- 1,056
- 5
- 18
- 38
9
votes
1 answer
Systemd timer will not fire
I have a timer that is literally this:
foobar.service:
[Unit]
Description=Timer Test
Requires=rsyslog.service # rsyslog is an active local service.
[Service]
Type=simple
ExecStart=/usr/bin/logger "Running foobar timer…
goldilocks
- 86,451
- 30
- 200
- 258
9
votes
2 answers
timer with multiple oncalendar moments
I'm using a systemd timer and unit to automatically trigger a backup job. But currently it runs only at one moment in the evening. Is it possible to have it run at multiple moments by declaring it in the same timer?
This is how it's…
aardbol
- 643
- 7
- 16
8
votes
1 answer
How to edit the timer for systemd-tmpfiles-clean?
I'm trying to change the cleanup interval for Apache PrivateTmp files from the default 30 days to 6 hours. I read that to edit the time intervals, I should set up an override file in /etc/tmpfiles.d/tmp.conf rather than editing…
arlomedia
- 183
- 1
- 1
- 6
8
votes
1 answer
How to start user systemd.timer (s) automatically?
I have setup few user systemd.timer(s).
How to make them start automatically ? (either on system start or once user logged into X session).
After I restart of the system (even systemctl --user enable was run before restart, i.e. does not help) I…
Grzegorz Wierzowiecki
- 13,865
- 23
- 89
- 137