I would like to execute a script every 30 min after booting into the system. I know you can use cron, but I don't plan to use this feature often therefore I'd like to try it with systemd.

So far I have only found the monotonic timers which allows to execute something once (at least I think so). How would the foo.timer and foo@user.service look like in case I wanted to execute something every 30 minutes from boot/system start?


Description=run foo

ExecStart=/bin/bash /home/user/script.sh


Description=run foo

where I am stuck... ???

3 Answers 3


You need to create two files: one for service, other for timer with same name.



Description=test job

ExecStart=/bin/bash /tmp/1.sh





after that reload the systemd using command systemctl daemon-reload and start your timer by systemctl start test.timer, or enable it by default (systemctl enable test.timer).

test content of 1.sh

echo `date` >> /tmp/2

And command to check all available timers: systemctl list-timers --all

More detailed info on project page and examples on ArchLinux page

  • 2
    please use systemctl list-timers --all command and check the output. He need to be like this. Look to unit, left and passed columns. If timer is present, please look to your service file and check for bugs there since timer working normally.
    – Reishin
    Apr 24, 2015 at 19:30
  • 2
    no, coz main question doesn't ask nothing about "notify-send" and i think we should not mix two different things when such topic already present. in your case, try to add export DISPLAY=:0.0 to the script.
    – Reishin
    Apr 24, 2015 at 20:26
  • 1
    ps: according to man systemd.timer the Persistent=true only has an effect on configured with OnCalendar (i.e. wallclock)
    – snyh
    Jul 28, 2016 at 2:58
  • 2
    Where is 30min set in your example? Aug 8, 2017 at 14:45
  • 2
    @KarlMorrison it is set to 10s in example, change value to 30min for full satisfaction expirience
    – Reishin
    Aug 8, 2017 at 15:29

Here is another option without using your timer. If timing is not terribly critical and and script isn't long running it will be fine for simple things.

Description=Run foo

ExecStart=/bin/bash /home/user/script.sh
  • 5
    I like this solution. The only major drawback is that system logs will be flooded with "Starting <service X>" logs if you restart often (i.e. every 30 seconds). At which point it might be better to run the service as a daemon instead, instead of restarting the service over and over from systemd. Aug 5, 2017 at 0:36
  • That's true. For quick and simple stuff it works. But the timer or a long running script would be a better solution.
    – hookenz
    Aug 5, 2017 at 3:09

The proper way is to use systemd-run you can schedule your job without the need to define your own unit.

It allows you to schedule by a calendar or every period of time. Assuming MYSELF is your full path application:

systemd-run --user --on-calendar '*:0/1' ${MYSELF} <args>
  • Does this run "every 30 minutes from boot/system start"? How would the OP adapt it to do that?
    – Jeff Schaller
    Dec 1, 2020 at 2:38
  • 1
    @JeffSchaller I'm about to try this out, but it looks like OP's requirement could be met with systemd-run --on-boot=1800 --on-unit-active=1800 /home/user/script.sh
    – Tony Park
    Nov 18, 2021 at 14:40
  • 1
    This should be the accepted answer, as op stated he wants to run a script, not explicitly create a service and a timer. systemd-run does that in the background without the user noticing.
    – m.w.
    Sep 15, 2022 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.